Help need with two vbscripts for roll out via SCCM
I need help with two scripts which i am trying to roll out via SCCM
I am trying to start a windows service which gets stopped after a SCCM roll out. I created another package which would use a vbs to restart the service and then reboot (using configmgr restarts computer).However the vbscript after successfully executing enabling the service does not end. It goes on for 120 minutes before giving an error that it could not be completed.I just need the program to end. Also the service should be enabled if it is stopped and then just skip if it is already enabled
attached in the below script
Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set colListOfServices = objWMIService.ExecQuery ("Select * from Win32_Service Where Name = '******'")
If colListOfServices.Count = 0 Then
Wscript.echo "Service ****** does not exists."
For Each objService in colListOfServices
strServiceStatus = objService.State
If strServiceStatus = "Stopped" Then
If Err.Number = 0 Then
Wscript.echo "Service ****** has been started & configuted to Automatic state."
Wscript.echo "Service ****** not started coz error " & Err.Number & ":" & Err.Description & " has occured."
Wscript.echo "Service ****** already in running state."
In this i am trying to block a package from running on a VM and to be installed only on desktops.When i run this the pop up comes stating that the software should not be installed but SCCM anyway goes ahead and installs it. Can the script be adjusted so that after the pop up it fails in execution on Vm machine but if it is run on desktops then successfully executed
On Error Resume Next Function Checkifvm Checkifvm = False
Set objWMIService = GetObject("winmgmts:" _
Set colManu = objWMIService.ExecQuery("Select * from Win32_Computersystem")
For Each objItem in colManu
If Instr(1, UCase(objItem.Manufacturer), "VMWARE", 1) Then
Checkifvm = True
End Function 'Checkifvm
Set objShell = CreateObject("Wscript.Shell") If Checkifvm Then
wscript.echo "This software should not be installed"
'Start command is machine is NOT vmware virtual machine
exexstr = "msiexec /i *****.msi /qb-!"
strError = objShell.Run (exexstr, 1, True) End If 'WScript.echo "Exit Code = " & strError