windows 7 - VBScript to stop service works in WinXP not in Win7 -
i have boot script copies ini files, based on os being used, mysql server. script works fine on winxp in win7 not stop service. no error reported. script appears run fine except fact ini files not copied if service running.
i have removed stop service portion of code , placed in script itself. however, still works on winxp , not on win7.
can see reason script not working?
sub stopservice(computername, servicename) dim service set service = getservice(computername, servicename) if(service nothing) call log.warning("the " & servicename & " service on " & computername & " computer not found") else service.stopservice() end if end sub function getservice(computername, servicename) dim wmiservice, objectslist, eobjectslist, objservice, item, sysid set wmiservice = getobject("winmgmts:{impersonationlevel=impersonate}!\\" & computername & "\root\cimv2") set objectslist = wmiservice.execquery("select * win32_service name = '" & servicename & "'") each objservice in objectslist if(objservice.name = servicename) set getservice = objservice exit function end if next set getservice = nothing end function stopservice ".", "mysql56"
thanks , help,
charles
Comments
Post a Comment