WWZee
WWZee

Reputation: 496

Close the cmd after running program?

I know next to nothing about the command prompt, and even less about windows 10, so I apologize if this isn't incredibly clear. I have an issue with Windows 10 permissions allowing a program to be run on standard users desktops. The way to fix this is to run the program "As Administrator" but I don't want the client to have to right click and have an admin come over every time this needs to be run. So after much googling (and I apologize I can't seem to find the website I picked this from), I found this line of code.

runas /user:admin_username /savecred "cmd /c \"C:\Users\Files\project.exe\""

and this is great! Circumvents the issue I was having (not 100% why though) and the user has to put in a password exactly once.

My problem is that this opens a second command prompt and it doesn't go away. I have tried to remove the /c part but that just opens a new prompt and doesn't execute my project.exe. Removing the "cmd /c" part doesn't work at all, saying "740: The requested ooperation requires elevation." which was the original error I was trying to avoid. I'm not sure how much it matters, but this command will then go into a shortcut so the user just has to double click an icon and then this will be executed.

So my question, how can I get this to open a second prompt, execute my .exe and then close the newly opened prompt?

EDIT: I managed to find the article I mentioned prior, AndreyT on 24 Nov 2015 is where I stole/borrowed the code from.

Upvotes: 0

Views: 292

Answers (1)

Compo
Compo

Reputation: 38613

Try the Start command:

RunAs /User:admin_username /SaveCred "Cmd /C Start \"\" \"C:\Users\Files\project.exe\""

Upvotes: 1

Related Questions