1

I'm trying to write a batch script that will open a new instance of CMD under different credentials, and automatically launch a program from that instance.

My "runas" command is:

runas /user:USER@DOMAIN cmd

After typing in a password, a new cmd instance opens, but I can't get it to automatically run the program I want.
How do I do this?
Also, if it's possible to close the new cmd instance after it launches the program, that will be helpful.

Thanks

3 Answers 3

4
runas /user:user:domain "cmd /c \"echo testing ^& pause ^& exit\"" 
  • quote the full command
  • inner quotes must be escaped as \"
  • inner problematic characters must be escaped as ^&, ^>, ...
Sign up to request clarification or add additional context in comments.

Comments

0

basically you want to pass an argument to the program you specify with runas

This article here suggests a way to do it

runas /profile /user:fabrikam\kenmyer "cscript.exe C:\Scripts\Test.vbs"

Comments

0

A user answered my question and then deleted his answer.
It worked for me, and I was too late to tick his answer, so I'm posting his answer here.

runas /user:USER@DOMAIN "cmd /c start program.exe"

This also closes the new CMD instance after launching "program.exe"
Thank you, kind stranger!

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.