Michael,
I tried your second script and got the following error:
C:\TEMP\test.vbs(4, 1) Microsoft VBScript runtime error: ActiveX component
can't
create object: 'GetObject'
I get this error on the "for each service" statement.. What's going on??
I'm running this on a Win2k Pro machine that was upgraded from NTW.
Troy
Quote:
> (Tip: if you use a fully qualified DNS name like "myserver.mycompany.com"
instead of the NetBIOS
Quote:
> name "myserver" you'll get slightly better GetObject performance)...
> For both ADSI and WMI you need to be in the Administrators group on the
remote box. For WMI, you
Quote:
> need WMI (preferably the same version) installed on both sides...
> ===============================================
> RemoteComputer = "whatever"
> Set MessengerServiceObj = GetObject("WinNT://" & RemoteComputer &
"/messenger")
> MessengerServiceObj.stop
> ===============================================
> RemoteComputer = "whatever"
> For each Service in
GetObject("winmgmts:{impersonationLevel=impersonate}!//" & RemoteComputer)_
Quote:
> .ExecQuery("select * from Win32_Service where Name='" & ServiceName &
"'")
> Service.StopService
> Next
> --
> Michael Harris
> Microsoft.MVP.Scripting
> --
> Please do not email questions - post them to the newsgroup instead.
> --
Quote:
> > Thanks Michael. I've seen those, but have 2 questions:
> > 1. How do I modify the script to execute against 'remote' NT machines.
> > 2. How do I check the 'return code' on stop/start requests??
> > Troy
> > > Both ADSI and WMI support access to services to query status,
stop/start,
> > etc.
> > > See Clarence's ADSI and WMI FAQs at
http://cwashington.netreach.net/script_repository/faqs.asp?topic=adsifaq
http://cwashington.netreach.net/script_repository/faqs.asp?topic=wmifaq
Quote:
> > > --
> > > Michael Harris
> > > Microsoft.MVP.Scripting
> > > --
> > > Please do not email questions - post them to the newsgroup instead.
> > > --
> > > > Can someone share some simple vbScript code with me to stop/restart
a
> > > > service on a Remote NT server?
> > > > Thanks,
> > > > Troy