Hi all,
I am trying to create a VB script which I can assign as a startup script
which will perform the following functions:
Check using Win32_Product for a software version 1 and if it exists
uninstall it
Check using Win32_Product for a software version 2 and if it exists
uninstall it
Install using Win32_Product software version 3
I have created the script and it works fine when I am logged in and double
click the vbs file. When I assign it as a start up script the machine takes
an extra 10 mins to start up!
Here is the code:
option explicit
dim strComputer
dim objWMIService
dim objSoftware
dim colSoftware
dim objService
dim objSoftware2
dim errReturn
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colSoftware = objWMIService.ExecQuery _
("Select name from Win32_Product Where Name = 'Name1")
For Each objSoftware in colSoftware
objSoftware.Uninstall()
Next
Set colSoftware = objWMIService.ExecQuery _
("Select name from Win32_Product Where Name = 'Name2'")
For Each objSoftware in colSoftware
objSoftware.Uninstall()
Next
Const ALL_USERS = True
Set objService = GetObject("winmgmts:")
Set objSoftware2 = objService.Get("Win32_Product")
errReturn = objSoftware2.Install("\\server\share$\software.msi", , ALL_USERS)
And here is what I get on the userenv.log around the slow time...
USERENV(244.240) 18:12:16:359 LoadProfileInfo: Failed to query central
profile with error 2
USERENV(244.240) 18:12:16:359 GetProfileType: ProfileFlags is 0
USERENV(2e0.2f0) 18:12:16:484 LibMain: Process Name:
C:\WINDOWS\System32\WScript.exe
USERENV(90.578) 18:12:16:515 ImpersonateUser: Failed to impersonate user
with 5.
USERENV(90.578) 18:12:16:515 GetUserNameAndDomain Failed to impersonate user
USERENV(90.578) 18:12:16:531 GetUserDNSDomainName: Domain name is NT
Authority. No DNS domain name available.
USERENV(90.4b0) 18:12:16:609 GetProfileType: Profile already loaded.
USERENV(90.4b0) 18:12:16:609 LoadProfileInfo: Failed to query central
profile with error 2
USERENV(90.4b0) 18:12:16:609 GetProfileType: ProfileFlags is 0
USERENV(914.918) 18:12:18:828 LibMain: Process Name:
C:\WINDOWS\system32\wbem\wmiprvse.exe
USERENV(938.93c) 18:12:19:031 LibMain: Process Name:
C:\WINDOWS\system32\msiexec.exe
USERENV(a28.a2c) 18:12:57:870 LibMain: Process Name:
C:\WINDOWS\system32\wuauclt.exe
USERENV(a78.a7c) 18:12:58:637 LibMain: Process Name:
C:\WINDOWS\system32\wbem\wmiprvse.exe
USERENV(bd8.bdc) 18:13:16:325 LibMain: Process Name:
C:\WINDOWS\system32\userinit.exe
USERENV(df0.df4) 18:21:21:091 LibMain: Process Name:
C:\WINDOWS\system32\MsiExec.exe
USERENV(e3c.e40) 18:21:28:187 LibMain: Process Name:
C:\WINDOWS\System32\WScript.exe
USERENV(ea4.ea8) 18:21:37:769 LibMain: Process Name:
C:\WINDOWS\system32\mpnotify.exe
USERENV(5d8.5dc) 18:21:37:815 LoadUserProfile: Yes, we can impersonate the
user. Running as self
Note the massive gap... I have put in various wscript.echo points along the
code to see where it is slowing but cannot seem to fix it... I need this to
be a system startup script because the users who login will not have enough
rights to perform this task... is there some kind of impersonation problem,
or is something not loading in the right order?? I am pretty stuck at this
point to be honest...