Running remote batch in elevated command

193 Views Asked by At

I have a windows service install batch file in a remote computer (Install.cmd).
When I run it as administrator, it works just fine.
But when I run a script (RemoteInstall.cmd) that run the remote install script, it complete all the steps beside start running.

From my computer -- RemoteInstall.cmd script:

START /WAIT clusrun /scheduler:RemotePc /nodes:RemotePc /user:Administrator /password:MyPass \\RemotePc\D$\Service\Install.cmd

On server -- Install.cmd script:

%WinDir%\Microsoft.NET\Framework\v4.0.30319\installutil MyService.exe
sc config "MyService" start= auto
sc config "MyService" obj= ".\Administrator" password= "MyPass"
sc failure "MyService" actions= restart/10000/restart/10000/restart/10000 reset= 86400
net start MyService

The last command returns errorlevel=2 when I run it from remote, while all the rest return errorlevel=0 if I run it locally or from remote. Same error occurs when I use sc instead of net.
How can I make it work?

0

There are 0 best solutions below