VBScript and WMI Custom Actions - Advanced Installer Community

We’re moving our forums to a new platform.

You can still browse and search existing topics, but you can no longer create new topics or post replies.

For questions, technical issues, or feature requests, please don’t hesitate to contact our support team at support@advancedinstaller.com.

Thank you for your understanding!

Runtorious
Posts: 1
Joined: Sat Aug 11, 2007 11:36 pm

VBScript and WMI Custom Actions

Hi Guy's,

Does any one know why this doesn't work when run as a custom action but it does when run under WSH?

===CODE===

strComputer = "."

Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")



Set SWBemlocator = CreateObject("WbemScripting.SWbemLocator")

Set objWMIService = SWBemlocator.ConnectServer(strComputer,"\root\CIMV2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_Service where Name = 'SgeClient'",,48)



For each objService in colItems

errServiceChange = objService.Change( , , , , , 0)

errServiceChange = objService.Change( , , , , , , "DOMAIN\ServiceAccount","")

errServiceChange = objService.Change( , , , , , , ,"password")

errServiceState = objService.StopService()

errServiceState = objService.StartService()

next



===END CODE===


Thanks,

Dwayne.
gigi
Posts: 2103
Joined: Tue Apr 11, 2006 9:55 am
Contact: Website

Hi Dwayne,

I'm afraid I'm not a VBScript expert. But what type of custom action you are using and with what options? From the script file I understand that you modify the user and password for some services.

In this case you need administrator privileges to run this script. So make sure you use a "Deferred" custom action. "Deferred with no impersonation" if you run under Windows Vista.

Regards,
Gigi
Gheorghe Rada
Advanced Installer Team
http://www.advancedinstaller.com/

Return to “Common Problems”