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.
This topic is 14 years and 10 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
dvendt
Posts: 48
Last visit: Fri May 27, 2011 3:44 am

2nd cmd window

Post by dvendt »

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
Last visit: Fri May 27, 2011 3:44 am

2nd cmd window

Post by dvendt »

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
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

2nd cmd window

Post by jvierra »

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
Last visit: Fri May 27, 2011 3:44 am

2nd cmd window

Post by dvendt »

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

runas /user:%computername%administrator "c:windowssystem32cmd.exe /c iexplore.exe"
This topic is 14 years and 10 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked