2nd cmd window

Batch, ASP, JScript, Kixtart, etc.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Locked
User avatar
dvendt
Posts: 48
Joined: Thu Dec 11, 2008 1:38 am

2nd cmd window

Post by dvendt » Thu Apr 23, 2009 6:10 am

I want to run the command "control powercfg.cpl" after I perform a runas. The problem is a 2nd cmd window is created and I don't know how to insert this command in there using a batch file. I added the pause, but not needed.
Here is what I have:

for /f %%i in ('hostname') do set local=%%irunas /user:%local%administrator c:windowssystem32cmd.exe pausecontrol powercfg.cpl

User avatar
dvendt
Posts: 48
Joined: Thu Dec 11, 2008 1:38 am

2nd cmd window

Post by dvendt » Thu Apr 23, 2009 6:10 am

I want to run the command "control powercfg.cpl" after I perform a runas. The problem is a 2nd cmd window is created and I don't know how to insert this command in there using a batch file. I added the pause, but not needed.
Here is what I have:

for /f %%i in ('hostname') do set local=%%irunas /user:%local%administrator c:windowssystem32cmd.exe pausecontrol powercfg.cpl

User avatar
jvierra
Posts: 13717
Joined: Tue May 22, 2007 9:57 am
Contact:

2nd cmd window

Post by jvierra » Thu Apr 23, 2009 6:47 am

Dio it this way. The method you are using will not work as expected at all time and may give unstable results.
{code]
runas /user:%computername%MyAdmin "c:windowssystem32cmd.exe /c powercfg.cpl"[/code]


I am assuming you are trying to run the powerpanel in a command window started with alt credentials.
jvierra2009-04-23 13:50:47

User avatar
dvendt
Posts: 48
Joined: Thu Dec 11, 2008 1:38 am

2nd cmd window

Post by dvendt » Wed May 20, 2009 3:12 am

how about bringing iexplore up instead, this doesn't work.

runas /user:%computername%administrator "c:windowssystem32cmd.exe /c iexplore.exe"

Locked