I want to execute a batch file
D:\apache-tomcat-6.0.20\apache-tomcat-7.0.30\bin\shutdown.bat
Which is on my server inidsoasrv01
.
How should I write my .bat
file?
I want to execute a batch file
D:\apache-tomcat-6.0.20\apache-tomcat-7.0.30\bin\shutdown.bat
Which is on my server inidsoasrv01
.
How should I write my .bat
file?
You can use WMIC or SCHTASKS (which means no third party software is needed):
1) SCHTASKS:
2) WMIC (wmic will return the pid of the started process)
If you are in same WORKGROUPyou need software to connect and control the target server.shutdown.exe /s /m \\<target-computer-name>
should be enoughshutdown /?
for more, otherwiseUPDATE:
Seems shutdown.bat here is for shutting down apache-tomcat.
So, you might be interested to psexec or PuTTY: A Free Telnet/SSH Client
As native solution could be
wmic
Example:
wmic /node:<target-computer-name> process call create "cmd.exe c:\\somefolder\\batch.bat"
In your example should be:
wmic /?
andwmic /node /?
for moreUse microsoft's tool for remote commands executions: PsExec
If there isn't your bat-file on remote host, copy it first. For example:
And then execute:
Note: filepath for psexec is path to file on remote server, not your local.
While I would recommend against this.
But you can use shutdown as client if the target machine has remote shutdown enabled and is in the same workgroup.
Example:
replacing
<target-computer-name>
with the URI for the target machine,Otherwise, if you want to trigger this through Apache, you'll need to configure the batch script as a CGI script by putting
AddHandler cgi-script .bat
andOptions +ExecCGI
into either a local.htaccess
file or in the main configuration for your Apache install.Then you can just call the
.bat
file containing theshutdown.exe
command from your browser.