VB script to change service startup

  • Thread starter Thread starter Patrick
  • Start date Start date
P

Patrick

Our network is having an issue with elections for a master
browser. to rule out the desktop pcs we are going to send
a "net stop browser" command to all PCs. after that we
would like to diable the Computer Browser Service with a
script.
The script I've created changes the registry entry to
disable the service. I've debugged it in Primal Script 3.0
and it returned no errors. When I test it on a machine, it
fails to change the registry entry. Altiris returned an
error 193 - needs reboot.
My question is: how do I change the registry entry for the
service without rebooting the machine.

Script:

Option Explicit
Dim WshShell
Dim WshNetwork

Set WshNetwork = WScript.CreateObject("WScript.Network")

Set WshShell = WScript.CreateObject("WScript.Shell")

WshShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Services\B
rowser\Start", "4", "REG_DWORD"
 
Patrick said:
(snip)
The script I've created changes the registry entry to
disable the service. I've debugged it in Primal Script 3.0
and it returned no errors. When I test it on a machine, it
fails to change the registry entry. Altiris returned an
error 193 - needs reboot.
My question is: how do I change the registry entry for the
service without rebooting the machine.

Script:
(snip)

Set WshShell = WScript.CreateObject("WScript.Shell")

WshShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Services\B
rowser\Start", "4", "REG_DWORD"

Hi

Running the three lines above changes the registry value on my computer and
sets the "Computer Browser" service to disabled.

You do run the script under an account that has admin rights on the local
computer?
 
Running the three lines above changes the registry value
on my computer and
sets the "Computer Browser" service to disabled.

You do run the script under an account that has admin rights on the local
computer?

yes i've also been tinkering with this script to try and
achieve the same result

strComputer = "."
Set Service = GetObject("winmgmts:"
& "{impersonationLevel=impersonate}!\\" & strComputer
& "\root\cimv2")
Service.Stop
Service.Change --->but i need to disable the service
 
yes i've also been tinkering with this script to try and
achieve the same result

strComputer = "."
Set Service = GetObject("winmgmts:"
& "{impersonationLevel=impersonate}!\\" & strComputer
& "\root\cimv2")
Service.Stop
Service.Change --->but i need to disable the service

Hi

Take a look here for some examples on using WMI (as well as ADSI that I prefer
over WMI) to handle services:

http://groups.google.com/[email protected]
 
Back
Top