Wednesday 11 March 2015

Service Start/Stop through VBScript - Advance Application Packaging


Hereby writting a simple VBScript to start and stop any service :


Option Explicit
On Error Resume Next

Dim strCmd

Dim WshShell
                                                                    
strCmd = "cmd.exe /c net stop Spooler"                  
Set WshShell = CreateObject("WScript.Shell")                                                    
WshShell.Run strCmd , 0, True                                                                                   
Set WshShell = Nothing


In above Example Spooler is service name.

To Start
strCmd = "cmd.exe /c net start Spooler" 

To Stop
strCmd = "cmd.exe /c net stop Spooler" 

some more parameter can be used with NET command are as below,

[ ACCOUNTS | COMPUTER | CONFIG | CONTINUE | FILE | GROUP | HELP | HELPMSG | LOCALGROUP | PAUSE | SESSION | SHARE | START | STATISTICS | STOP | TIME | USE | USER | VIEW ]

Thank you for reading.

1 comment: