clivebuckwheat Posted June 13, 2010 Share Posted June 13, 2010 On first login. It checks what type of machine type it is and based on that I would like it to install this program that is proprietary to our organization. Right now I am testing in a virtual machine so that why the script has been modified for use with a Virtual.I am calling it via the sysprep.I get the following errorGet the SMBIOS asset tag from the Win32_SystemEnclosure classDim objWMISet objResults = objWMI.InstancesOf("Win32_SystemEnclosure")Option ExplicitDim strComputer, strChassisDim objWMIService, objInstance, objResults, objItemstrComputer = "."Set objWMIService = GetObject("winmgmts:" _& "{impersonationLevel=impersonate}!\\" _& strComputer & "\root\cimv2")Set objResults = objWMIService.ExecQuery _("Select * from Win32_SystemEnclosure",,16)Dim bIsLaptop, bIsDesktop, bIsServer, bIsVirtual, sAssetTag, objShellApp, isRunningbIsLaptop = falsebIsDesktop = falsebIsServer = falsebIsVirtual = falseFor each objInstance in objResults If objInstance.ChassisTypes(0) = 12 or objInstance.ChassisTypes(0) = 21 then ' Ignore docking stations Else If not IsNull(objInstance.SMBIOSAssetTag) then sAssetTag = Trim(objInstance.SMBIOSAssetTag) End if Select Case objInstance.ChassisTypes(0) Case "2" bIsVirtual = true Case "8", "9", "10", "11", "12", "14", "18", "21" bIsLaptop = true Case "3", "4", "5", "6", "7", "15", "16" bIsDesktop = true Case "23" bIsServer = true Case Else ' Do nothing End Select End ifNextIf bIsVirtual = true then Set objShellApp = CreateObject("WScript.Shell") Set isRunning = objShellApp.Exec("msiexec /i C:\WINDOWS\Clara.msi /passive /norestart")End if Link to comment Share on other sites More sharing options...
cluberti Posted June 13, 2010 Share Posted June 13, 2010 This compiled and ran just fine:Option ExplicitDim strComputer, strChassisDim objWMIService, objInstance, objResults, objItemDim bIsLaptop, bIsDesktop, bIsServer, bIsVirtual, sAssetTag, objShellApp, isRunningbIsLaptop = FalsebIsDesktop = FalsebIsServer = FalsebIsVirtual = FalseRunMeWithCScript()strComputer = "."Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")Set objResults = objWMIService.ExecQuery( _ "SELECT * FROM Win32_SystemEnclosure",,48)For Each objInstance in objResults If objInstance.ChassisTypes(0) = 12 or objInstance.ChassisTypes(0) = 21 Then ' Ignore docking stations Else If Not IsNull(objInstance.SMBIOSAssetTag) Then sAssetTag = Trim(objInstance.SMBIOSAssetTag) End If Select Case objInstance.ChassisTypes(0) Case "2" bIsVirtual = True Case "8", "9", "10", "11", "12", "14", "18", "21" bIsLaptop = True Case "3", "4", "5", "6", "7", "15", "16" bIsDesktop = True Case "23" bIsServer = True Case Else ' Do nothing End Select End IfNextIf bIsVirtual = False Then Set objShellApp = CreateObject("WScript.Shell") Set isRunning = objShellApp.Exec("msiexec /i C:\WINDOWS\Clara.msi /passive /norestart")End IfSub RunMeWithCScript() Dim ScriptEngine, engineFolder, Args, arg, scriptName, argString, scriptCommand ScriptEngine = UCase(Mid(WScript.FullName, InstrRev(WScript.FullName, "\") + 1)) engineFolder = Left(WScript.FullName, InstrRev(WScript.FullName, "\")) argString = "" 'WScript.Echo ScriptEngine If ScriptEngine = "WSCRIPT.EXE" Then Dim Shell Set Shell = CreateObject("WScript.Shell") Set Args = WScript.Arguments For Each arg in Args 'loop though argument array as a collection to rebuild argument string If InStr(arg, " ") > 0 Then arg = """" & arg & """" 'If the argument contains a space wrap it in double quotes argString = argString & " " & Arg Next 'Create a persistent command prompt for the cscript output window and call the script with its original arguments scriptCommand = "cmd.exe /k " & engineFolder & "cscript.exe """ & WScript.ScriptFullName & """" & argString Shell.Run scriptCommand, , False WScript.Quit Else Exit Sub 'Already Running with Cscript Exit this Subroutine End IfEnd Sub Link to comment Share on other sites More sharing options...
gunsmokingman Posted June 13, 2010 Share Posted June 13, 2010 if this is the first line of the scriptGet the SMBIOS asset tag from the Win32_SystemEnclosure classit should be like this to avoid the error, your missing the comment out '' Get the SMBIOS asset tag from the Win32_SystemEnclosure class Link to comment Share on other sites More sharing options...
myselfidem Posted June 13, 2010 Share Posted June 13, 2010 Hello Your question is solved:http://www.msfn.org/board/index.php?showtopic=144408&st=20Thanks to cluberti for his precious help! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now