Script to determine model

 

转自http://www.altirigos.com/vbulletin/deployment-server/6691-script-determine-model.html

Script to determine model

Just a quick to see if anyone has an example of a script to determine the Model of a computer? I just need to push software to various machines and would like to have it determine the Model and then install the appropriate software. I believe I have to go with a field in the DB like %#!computer@prod_name% or somehting like that? Any help would be greatly appreciated?
cocodmonkey is offline   Reply With Quote
Old 05-24-2007, 10:52 PM   #2 (permalink)
Altiris Architect (Site Founder)
  Nick's Avatar
 
Join Date: 01-01-2005
Location: RDU, North Carolina, USA
Posts: 4,650
I would suggest using conditions to this rather than a script.
__________________ Scire potentia est (knowledge is power)
Nick is offline   Reply With Quote
Old 05-24-2007, 11:15 PM   #3 (permalink)
Junior Altiris Admin
  cocodmonkey's Avatar
 
Join Date: 05-17-2005
Location: Australia
Age: 33
Posts: 19
Conditions

Yeah i looked at conditions but they encompass the whole job? i want to run a script after an HII imaging job to install all those platform specific pieces of software?
cocodmonkey is offline   Reply With Quote
Old 05-25-2007, 08:42 AM   #4 (permalink)
Altiris Architect (Site Founder)
  Nick's Avatar
 
Join Date: 01-01-2005
Location: RDU, North Carolina, USA
Posts: 4,650
Is your HII just an image or is there some sort of firm injection going on?
__________________ Scire potentia est (knowledge is power)
Nick is offline   Reply With Quote
Old 05-27-2007, 07:10 PM   #5 (permalink)
Junior Altiris Admin
  cocodmonkey's Avatar
 
Join Date: 05-17-2005
Location: Australia
Age: 33
Posts: 19
HII Process

There is a firm injection process going on for Drivers and some other generic software.
cocodmonkey is offline   Reply With Quote
Old 05-27-2007, 09:10 PM   #6 (permalink)
Altiris Architect (Site Founder)
  Nick's Avatar
 
Join Date: 01-01-2005
Location: RDU, North Carolina, USA
Posts: 4,650
If you use conditions there are a couple of ways to go.
  1. Create a condition for each model (firm injection) and then include the other steps within each condition... software install etc
  2. Create a condition for each model (firm injection) then have a success code criteria point to another job that would do the software install.
You could also use a script to do this but with a script you're losing your ability to track individual error codes for each step of the task. Just my opinion.
__________________ Scire potentia est (knowledge is power)
Nick is offline   Reply With Quote
Old 05-27-2007, 09:24 PM   #7 (permalink)
Junior Altiris Admin
 
Join Date: 09-24-2006
Location: Australia
Posts: 17
This is how we do it the below as part of our Hii.bat that runs after the imag has been pushed to the client. Hope this helps echo hardware model is %#!computer@model_num% echo " %#!computer@prod_name%" > a:/model.txt echo Computer model is " %#!computer@prod_name%" type a:/model.txt|find "Latitude D420" if NOT ERRORLEVEL 1 goto D420 type a:/model.txt|find "HP d530" if NOT ERRORLEVEL 1 goto HPD530 type a:/model.txt|find "HP Compaq dc7100" if NOT ERRORLEVEL 1 goto HPdc7100 if "%#!computer@model_num%" == "085Ch" goto HPD530 if "%#!computer@model_num%" == "097Ch" goto HPdc7100
Cathossie is offline   Reply With Quote
Old 05-28-2007, 07:26 AM   #8 (permalink)
Junior Altiris Admin
  Robert Lundsten's Avatar
 
Join Date: 12-20-2005
Location: Sweden
Age: 33
Posts: 24
I have developed a simple solution to get the computer model in Altiris. The problem today is that some computers does not report a easy-to-use model number. A good example is IBM. Here is what you do; 1. Start SQL query analyzer and run the following SQL script; USE eXpress GO CREATE FUNCTION [dbo].[fnGetComputerModelID] ( @ComputerID int, @Type int ) RETURNS nvarchar(8) AS BEGIN DECLARE @TempString nvarchar(100) DECLARE @ModelID nvarchar(8) DECLARE @ModelNumber nvarchar(100) DECLARE @ProductName nvarchar(100) SET @ModelNumber = (SELECT UPPER(model_num) FROM computer WHERE computer_id = @ComputerID) SET @ProductName = (SELECT UPPER(prod_name) FROM computer WHERE computer_id = @ComputerID) SET @ModelNumber = REPLACE(@ModelNumber, ' ', '') SET @ModelNumber = REPLACE(@ModelNumber, '_', '') SET @ModelNumber = REPLACE(@ModelNumber, '-', '') SET @ModelNumber = REPLACE(@ModelNumber, '(', '') SET @ModelNumber = REPLACE(@ModelNumber, ')', '') SET @ModelNumber = REPLACE(@ModelNumber, '#', '') SET @ProductName = REPLACE(@ProductName, ' ', '') SET @ProductName = REPLACE(@ProductName, '_', '') SET @ProductName = REPLACE(@ProductName, '-', '') SET @ProductName = REPLACE(@ProductName, '(', '') SET @ProductName = REPLACE(@ProductName, ')', '') SET @ProductName = REPLACE(@ProductName, '#', '') -- Set Model ID using Model Number IF @Type = 1 BEGIN SET @ModelID = @ModelNumber END -- Set Model ID using Product Name IF @Type = 2 BEGIN SET @ModelID = @ProductName END -- Set Model ID using Model Number and Product Name IF @Type = 3 BEGIN SET @ModelID = CAST(@ModelNumber AS nvarchar(4)) + CAST(@ProductName AS nvarchar(4)) END -- Set Model ID using special method IF @Type = 4 BEGIN SET @ModelID = SUBSTRING(@ModelNumber, 1, 1) + SUBSTRING(@ProductName, 7, 1) + SUBSTRING(@ModelNumber, 2, 1) + SUBSTRING(@ProductName, 5, 1) + SUBSTRING(@ModelNumber, 3, 1) + SUBSTRING(@ProductName, 3, 1) + SUBSTRING(@ModelNumber, 4, 1) + SUBSTRING(@ProductName, 1, 1) END RETURN @ModelID END GO 2. Create a task in DS that copies drivers; SET MODELID=%#*"SELECT [dbo].[fnGetComputerModelID] (%ID%, X)"% FIRM.EXE -recurse copy F:/DRIVERS/%MODELID%/*.* PROD:/DRIVERS You have now 4 different method to get the computer model. Just replace X above with 1-4. The SQL function returns max 8 chars which makes it easy to create a folder structure. And you have the option to use model number or product name... Hope it helps!
__________________ Robert Lundsten Altiris Specialist Asterio AB, Sweden www.asterio.se
Robert Lundsten is offline   Reply With Quote
Old 05-28-2007, 08:36 AM   #9 (permalink)
Altiris Architect (Site Founder)
  Nick's Avatar
 
Join Date: 01-01-2005
Location: RDU, North Carolina, USA
Posts: 4,650
Nice bit of code Robert.
__________________ Scire potentia est (knowledge is power)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值