How to run commands on cmd prompt

Jun 15, 2017 at 8:33pm
All I need is to open cmd prompt as administrator and pass few commands to there.

I already have:
 
  system("powershell -Command Start-Process 'C:\\Windows\\System32\\cmd.exe' -Verb runAs");


Now I want pass some commands and then exit this cmd, but everything below this line is done in main cmd.
Last edited on Jun 15, 2017 at 8:36pm
Jun 15, 2017 at 11:51pm
its not like that.

System sends ONE command to the OS. It does not really open a console and play human at it.

you can either do each command in turn with a set of system calls, or you can write a batch file that does them all and call that from your code. Unix lets you put ; between statements to invoke multiple at once, I can't recall if dos does or not, but you can try it
Jun 16, 2017 at 7:01am
I tried separate statements with ; & && and they are not working how I want. First command open cmd as Administrator, but second and third commands are done in main cmd.
Jun 21, 2017 at 9:14pm
Ok, I think it's impossible to do this. I will just open my program as Administrator and there I will pass some commands.
Topic archived. No new replies allowed.