This is my batch file script:

::opens new cmd in admin mode
powershell.exe -Command "Start-Process cmd -Verb RunAs" 

::this needs to execute in the previously, newly opened cmd
wmic product where name="xxx" call uninstall /nointeractive

To use the wmic it requires an elevated administrator command prompt. I found the powershell command which actually opens the cmd in admin mode, however, when I try to run the following instruction, it selects the original command prompt which is not in admin mode...

Is there any way to continue the execution of my script in the newly opened cmd window?


One way is to store the command(s) you want to pass to cmd in a batch file, then call the batch file instead of cmd.

Eg, file.bat:

wmic product where name="xxx" call uninstall /nointeractive

Then call the script the same way you were attempting to,

powershell.exe -Command "Start-Process file.bat -Verb RunAs" 
| improve this answer | |
  • is it possible to pass in parameters via the powershell.exe script? I.e. installer.bat 2000 -u and then: powershell.exe -Command "Start-Process file.bat %arg1% %arg2% -Verb RunAs" – benscabbia Jul 14 '16 at 14:17
  • Your comment is off topic to the original question. Yes, it is possible. You should do some more research on exchanging parameters between batch/Powershell and, if you have troubles, post a new question. – root Jul 14 '16 at 14:22
  • I'll do some further research and post new question if required. Thanks again! – benscabbia Jul 15 '16 at 7:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.