Script to determine model

来源:互联网 发布:淘宝王府井百货靠谱么 编辑:程序博客网 时间:2024/06/05 18:21

 

转自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)
Nick
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)
cocodmonkey
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)
Nick
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)
cocodmonkey
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)
Nick
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)
Cathossie
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 helpsecho hardware model is %#!computer@model_num%echo " %#!computer@prod_name%" > a:/model.txtecho 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 HPD530type a:/model.txt|find "HP Compaq dc7100"if NOT ERRORLEVEL 1 goto HPdc7100if "%#!computer@model_num%" == "085Ch" goto HPD530if "%#!computer@model_num%" == "097Ch" goto HPdc7100
Cathossie is offline   Reply With Quote
Old 05-28-2007, 07:26 AM   #8 (permalink)
Robert Lundsten
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 eXpressGOCREATE FUNCTION [dbo].[fnGetComputerModelID]( @ComputerID int,@Type int) RETURNS nvarchar(8)ASBEGIN 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 NumberIF @Type = 1 BEGINSET @ModelID = @ModelNumberEND-- Set Model ID using Product NameIF @Type = 2 BEGINSET @ModelID = @ProductNameEND-- Set Model ID using Model Number and Product NameIF @Type = 3 BEGINSET @ModelID = CAST(@ModelNumber AS nvarchar(4)) + CAST(@ProductName AS nvarchar(4))END-- Set Model ID using special methodIF @Type = 4 BEGINSET @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)ENDRETURN @ModelIDENDGO2. Create a task in DS that copies drivers;SET MODELID=%#*"SELECT [dbo].[fnGetComputerModelID] (%ID%, X)"%FIRM.EXE -recurse copy F:/DRIVERS/%MODELID%/*.* PROD:/DRIVERSYou 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 LundstenAltiris SpecialistAsterio AB, Swedenwww.asterio.se
Robert Lundsten is offline   Reply With Quote
Old 05-28-2007, 08:36 AM   #9 (permalink)
Nick
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)
原创粉丝点击