I'm trying (under Windows 7) to use the runas command to stop then restart a service. (Win7 requires admin privs to do this; thus the use of runas.)
Stopping the service works fine, but starting it does not. Here's the command I'm using for stopping the service:
runas /user:myDomain\myUserId "net stop serviceName"
Here's the command for starting the service:
runas /user:myDomain\myUserId "net start serviceName"
When I run the above command another command window opens, but flashes away before I can see anything in it; thus I have no idea what's going wrong.
So, my question is: How might I capture stdout and/or stderr from the net start command when run via runas? I've tried just using redirection but just get an empty file. Another solution would be to get the window opened by runas for the subtask to remain open.
Thanks in advance.