Script_to_Select_Computer

Kapalı İlan edilme: Dec 23, 2008 Teslim sırasında ödenir
Kapalı Teslim sırasında ödenir

LeRoy B. Meyer@[url removed, login to view]

919-501-9040

Project:

With the enclosed VBScript,

?

1.? Leaving most of the code intact, especially the reading machine Bios to determine machine type.

2.? modify it so that there will be a table of computer models to select from instead of the "If this DXxxxx model run [url removed, login to view]"

And;

3.? Then create another VBScript that will load a RAM Disk .wim (XP/SP3) file based on compter model.

## Deliverables

**************************************************************************

'** PROGRAM: MachineType

'** PURPOSE: Reads the Machine Type information from the BIOS and then

'**? ? runs the setup scripts for that model.?

'**

'** NOTE(s):

'**? - If the model is undefined, a message box will appear with the info

'**? ? ? ? needed to update the script.? YOU MUST get the EXACT string.

'**? ? ? ? See Armada M700 for an example (4spaces)

'**

'** LOGGING:

'**? ? C:\Installs\USPS\[url removed, login to view]

'**

'** HISTORY:

'**? ? 02192004 BryFrey Original

'**? ? 05/21/2007 Lee Meyer

'**

'**************************************************************************

' Option Explicit

'[url removed, login to view] "System Specific Software now needs to be installed. Click OK to start the process. Then Please Wait! The System will restart when the process is complete"

' On Error Resume Next

Dim iPRINT_ON, LogFile, strComputer, objWMIService, colItems, sManuf, sModel, objItem? ?

LogFile="C:\Installs\USPS\[url removed, login to view]"

CreateLogFile(LogFile)

'Get Machine Manuf & Model info:

strComputer = "."

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set colItems = [url removed, login to view]("Select * from Win32_ComputerSystem",,48)

For Each objItem In colItems

? ? sManuf =Trim([url removed, login to view])

? ? sModel =UCase(Trim([url removed, login to view]))

Next

[url removed, login to view] "Manufacturer= " & sManuf

[url removed, login to view] "Model? ? ? ? ? ? = " & sModel

'* Assume we found a match.? We will set this FALSE if we didn't

bSETUP =1

'***********************************************************************

'* Parse the Model and run the setup for that specific machine

'* NOTE!!!

'*? MAKE SURE that you put these in the correct order

'*? ie: "N400C" (actual "EVO N400C") MUST be before "EVO"

If (Instr(1, sModel, "D220", 1) <>0) Then

? ? Print "Doing '" &sModel &"' Setup..."

? ? RunCmd "C:\installs\Updates\[url removed, login to view]","" ,True 'Run [url removed, login to view], no switches, wait for it to complete

Elseif (Instr(1, sModel, "D310", 1) <>0) Then

? ? Print "Doing '" &sModel &"' Setup..."

? ? RunCmd "C:\installs\Updates\[url removed, login to view]","" ,True ?

Elseif (Instr(1, sModel, "DC5000", 1) <>0) Then

? ? Print "Doing '" &sModel &"' Setup..."

? ? RunCmd "C:\installs\Updates\[url removed, login to view]","" ,True

Elseif (Instr(1, sModel, "DX2000", 1) <>0) Then

? ? Print "Doing '" &sModel &"' Setup..."

? ? RunCmd "C:\installs\Updates\[url removed, login to view]","" ,True

Elseif (Instr(1, sModel, "DX2200", 1) <>0) Then

? ? Print "Doing '" &sModel &"' Setup..."

? ? RunCmd "C:\installs\Updates\[url removed, login to view]","" ,True

Elseif (Instr(1, sModel, "DC5100", 1) <>0) Then

? ? Print "Doing '" &sModel &"' Setup..."

? ? RunCmd "C:\installs\Updates\[url removed, login to view]","" ,True

Elseif (Instr(1, sModel, "DC5700", 1) <>0) Then

? ? Print "Doing '" &sModel &"' Setup..."

? ? RunCmd "C:\installs\Updates\[url removed, login to view]","" ,True

Elseif (Instr(1, sModel, "DC5100", 1) <>0) Then

? ? Print "Doing '" &sModel &"' Setup..."

? ? RunCmd "C:\installs\Updates\[url removed, login to view]","" ,True

Elseif (Instr(1, sModel, "NC6220", 1) <>0) Then

? ? Print "Doing '" &sModel &"' Setup..."

? ? RunCmd "C:\installs\Updates\[url removed, login to view]","" ,True

Elseif (Instr(1, sModel, "NC6400", 1) <>0) Then

? ? Print "Doing '" &sModel &"' Setup..."

? ? RunCmd "C:\installs\Updates\[url removed, login to view]","" ,True

Elseif (Instr(1, sModel, "DX2300", 1) <>0) Then

? ? Print "Doing '" &sModel &"' Setup..."

? ? RunCmd "C:\installs\Updates\[url removed, login to view]","" ,True

Elseif (Instr(1, sModel, "DX2400", 1) <>0) Then

? ? Print "Doing '" &sModel &"' Setup..."

? ? RunCmd "C:\installs\Updates\[url removed, login to view]","" ,True

Elseif (Instr(1, sModel, "DC5800", 1) <>0) Then

? ? Print "Doing '" &sModel &"' Setup..."

? ? RunCmd "C:\installs\Updates\[url removed, login to view]","" ,True

Elseif (Instr(1, sModel, "DSDT", 1) <>0) Then

? ? Print "Doing '" &sModel &"' Setup..."

? ? RunCmd "C:\installs\Updates\[url removed, login to view]","" ,True

'* NOTE: EVO needs to be last because other models contain "EVO" in their string!

Elseif (Instr(1, sModel, "EVO", 1) <>0) Then

? ? Print "Doing '" &sModel &"' Setup..."

? ? RunCmd "C:\installs\Updates\[url removed, login to view]","" ,True 'Run [url removed, login to view], no switches, wait for it to complete

'** Did not find a match

Else

? ? bSETUP=0

? ? Print "ERROR: Unknown Machine Type: Manufacturer: '" & sManuf &"'" &vbCrlf &"? Model: '" & sModel &"'"

? ? MsgBox "Contact Support with the following information" & vbCrlf & "? Manufacturer: '" & _

? ? ? ? ? ? ? sManuf &"'" &vbCrlf &"? Model: '" & sModel &"'" & vbCrlf &vbCrlf & "No updates have been applied!", _

? ? ? ? ? ? ? vbOkonly +vbCritical, "Unknown Computer Model!"

End If

'Add any common setup items here

Print "Starting Common Setup Items..."

SetMachineName

SetMachineName

'Sample of running a command

'RunCmd "C:\installs\Updates\[url removed, login to view]", "", TRUE

?

const HKEY_LOCAL_MACHINE = &H80000002

strComputer = "."

Set StdOut = [url removed, login to view]

?

Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_

strComputer & "\root\default:StdRegProv")

?

'strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce"

'strValueName = "RunJoinNote"

'strValue = "wscript C:\installs\fru\[url removed, login to view]"

'[url removed, login to view] HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue

'Add any common cleanup items here

'? ie: Delete files in Temp folder

Print "Starting Common Cleanup..."

'? RunCmd "C:\Windows\System32\[url removed, login to view]", "/C DEL /F /Q C:\TEMP\*.*", TRUE

?

'If we ran the machine scripts, then we need to cleanup stuff

If (bSETUP) Then

? ? Print "Starting Machine Script Cleanup..."

? 'Add any Cleanup here

? ' ie: Delete ALL machine specific scripts

End If

?

'We are done

Print "Setup Complete " &now

Print " Rebooting..."

iPRINT_ON =0

RunCmd "C:\Windows\System32\[url removed, login to view]", "-r -t 0", False

? ? ? ?

[url removed, login to view]

'***************************************************************************************

'* Function Section:? This is where we add any helper functions that are needed

'**************************************************************************************

'* CreateLogFile: Creates the log file and writes the initial line to it

Function CreateLogFile(LogFile)

? Dim fso, LogFileName, LogFilePath

?

? 'Default to failure

? iPRINT_ON =0

?

? Set fso = [url removed, login to view]("[url removed, login to view]")?

? LogFileName =[url removed, login to view](LogFile)

? LogFilePath =[url removed, login to view](LogFile)

? If [url removed, login to view](LogFilePath) Then

? ? ? '[url removed, login to view] LogFilePath & " exists"

? ? ? iPRINT_ON =1

? Else

? ? ? '[url removed, login to view] LogFilePath & " Does not exist"

? ? ? [url removed, login to view](LogFilePath)

? ? ? If [url removed, login to view](LogFilePath) Then

? ? ? ? ? ? iPRINT_ON =1

? ? ? Else

? ? ? ? ? ? iPRINT_ON =0

? ? ? ? ? ? MsgBox "Unable to create log file '" &LogFile &"'", vbOkonly +vbCritical, "Error!"

? ? ? End If

? ? ?

? End If

?

? If iPRINT_ON Then

? ? ? If [url removed, login to view](LogFile) Then

? ? ? ? ? ? 'Append a blank line

? ? ? ? ? ? Print ""? ? ?

? ? ? End If

? ? ? Print "*********************************************************************************"

? ? ? Print "Log Started: " &Now

? End If

?

? Set fso =Nothing?

?

? CreateLogFile =iPRINT_ON

End Function

'**************************************************************************************

'* Print: Prints text to the log file

Sub Print(Str)

? ? Dim fso, filetxt

? ?

? ? If iPRINT_ON Then

? ? ? 'Append the new output to our logfile.

? ? ? ? ? Set fso = [url removed, login to view]("[url removed, login to view]")? ?

? ? ? ? ? Set filetxt = [url removed, login to view](LogFile, 8, True, 0)

? ? ? ? ? If (Str ="") Then

? ? ? ? ? ? ? ? [url removed, login to view]("")

? ? ? ? ? Else

? ? ? ? ? ? ? ? [url removed, login to view](now &": " &Str)

? ? ? ? ? End If

? ? ? ? ? [url removed, login to view]

? ? ? ? ?

? ? ? ? ? Set filetxt =Nothing

? ? ? ? ? Set fso = Nothing

? ? End If

End Sub

'**************************************************************************************

'* SetMachineName: Sets the Machine Name to the system's Serial Number

Function SetMachineName()

? ? On Error Resume Next

? ? Print "Setting Machine Name..."

? ?

? ? 'Default to failed

? ? SetMachineName =FALSE

? ? strComputer = "."

? ? Dim sSNUM

? ? Dim sOldName

? ? Dim oArgs

? ? Dim oWMIS, colItems, objItem

? ? 'Get Serial Number

? ? Set oWMIS = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

? ? Set colItems = [url removed, login to view]("Select * from Win32_BIOS",,48)

? ? For Each objItem in colItems

? ? ? ? ? sSNUM = Trim([url removed, login to view])

? ? Next

? ? 'Get Computer Name

? ? 'Set oWMIS = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

? ? Set colItems = [url removed, login to view]("Select * from Win32_ComputerSystem",,48)

? ? For Each objItem in colItems

? ? ? ? ? ? sOldName =Trim([url removed, login to view])

? ? Next

? ? 'Set the computer name to the SerialNumber

? ? sName = sSNUM

? ? If (sName <>"") Then

? ? ? ? ? If (sName <>sOldName) Then

? ? ? ? ? ? ? ? 'Set oWMIS = GetObject("Winmgmts:root\cimv2")

? ? ? ? ? ? ? ? ' Call always gets only one Win32_ComputerSystem object.

? ? ? ? ? ? ? ? For Each objComputer in [url removed, login to view]("Win32_ComputerSystem")

? ? ? ? ? ? ? ? ? ? ? ? 'We don't need the args since we are running as admin

? ? ? ? ? ? ? ? ? ? ? ? 'Return = [url removed, login to view](sName, Password, Username)? ? ?

? ? ? ? ? ? ? ? ? ? ? ? Return = [url removed, login to view](sName)

? ? ? ? ? ? ? ? ? ? ? ? If Return <> 0 Then

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Print " ERROR: Rename failed (" &sOldName &" to " &sName &").? RC=" &Return _

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? &"? Error=" & [url removed, login to view]

? ? ? ? ? ? ? ? ? ? ? ? Else

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Print "? Rename succeeded (" &sOldName &" to " &sName &"). Reboot For new name To go into effect"

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? SetMachineName =TRUE

? ? ? ? ? ? ? ? ? ? ? ? End If

? ? ? ? ? ? ? ? Next

? ? ? ? ? Else

? ? ? ? ? ? ? ? Print "? Name was already set to " &sName

? ? ? ? ? ? ? ? SetMachineName =TRUE

? ? ? ? ? End If

? ? Else

? ? ? ? ? Print "? ERROR: Unable to find the SerialNumber to rename the system to!" &vbCrlf _

? ? ? ? ? ? ? ? ? ? ? ? &"System is still named: " &sOldName

? ? End If

End Function

'**************************************************************************************

'* RunCmd: Runs the command with the arguments specified.? bWAIT (TRUE/FALSE) says if

'*? ? we wait for the command to complete before we continue.

'*? ie: RunCmd "c:\windows\[url removed, login to view]", "[url removed, login to view]", TRUE

'*? ? ? ? Opens Notepad with file "[url removed, login to view]" and waits for it to close

Function RunCmd(sCmd, sArgs, bWAIT)

? ? Dim oWSH, oFSO, rc

? ? On Error Resume Next

? ? Print "RunCmd(" &sCmd &" "&sArgs &")"? ?

? ? Set oWSH =CreateObject("[url removed, login to view]")

? ? 'Make sure the file exists

? ? Set oFSO =CreateObject("[url removed, login to view]")

? ? If [url removed, login to view](sCmd) then

? ? ? ? ? '? ? 1=Normal, 2=Minimized

? ? ? ? ? rc =[url removed, login to view](sCMD &" " &sArgs, 1, bWAIT)

? ? ? ? ? Print "? Result:" &rc

? ? Else

? ? ? ? ? Print "? ERROR: Unable to find: '" &sCmd &"'"

? ? End if

? ? Set oFSO =Nothing

? ? Set oWSH =Nothing? ? ? ? ?

End Function

Mühendislik Microsoft MySQL PHP Proje Yönetimi Yazılım Mimarisi Yazılım Test Etme Windows Masaüstü

Proje NO: #3493094

Proje hakkında

Uzak proje Aktif Jan 15, 2009