This question already has answers here:
Opening up Windows Terminal with elevated privileges, from within Windows Terminal
(13 answers)
Closed 2 years ago.
I'm looking for a way to be able to open cmd as admin with code. So like linux. We just execute "sudo su" command for be admin. But ı want this for windows. So ı want execute a command in cmd like "sudo su" and be admin. How can ı do this?
You should run:
runas /user:administrator cmd
then enter the administrator password.
runas /savecred /user:myadminaccount "myprocess.exe"
if ypu mean open an administrative commandline you havd a few options:
1: Right click run as adminiatrator on the cmd shortcut or executable
2: Right click, open properties of shortcut or exe, click "run with administrator priviledges" and click okay, now when you open it it launches as administrator
3: launch cmd from a powershell session specifying to run cmd as administrator
4: from wirhin cmd, run powershell directly, with the appropriate switches to run it as administrator.
-- Not at my computer and dont remember the powershell commands needed to do this offhand.
So I will fill that in later if this is the needed solution, or anothwr member may do so ofc. either by editing this or answering seperately.
just let us know if that was the real need you wanted.
Related
I am trying to open a Command Prompt as administrator, (elevated), from a normal user privileged Command Prompt.
I searched Google a lot, but cannot find a method to achieve it.
Is there any CLI command, to open an Administrator: Command Prompt, from a normal Command Prompt?
Thanks in advance!
I don't know the meaning or any other explanation for this command but, it works with all Windows Operating system's (Windows 7,8,8.1,10,11 - Tested). Run this command in your normal user privileged Command Prompt Which will open another Administrator: CMD window.
powershell -Command "Start-Process cmd -Verb RunAs"
I got this Command from Google while searching on the Internet. If anybody know the meaning of this command plz update (Edit) my Answer!
There is no such command. Cmd needs to be invoked with the credentials you want to use. So changing users like for example in Terminal on Ubuntu is not possible at the moment. You can open a new Terminal by using
runas /user:(UserNameHere) CMD.exe
I use Windows 10 and in cmd I want to use the command
sfc /scannow
Cmd then gives me this message
You must be an administrator running a console session in order to use the sfc utility.
I then try to open cmd by right-clicking and press Run as Administrator.
But then I get this error. How can I solve this?
Firstly, the error is not related to cmd.exe running as admin. You probably have something incorrectly assigned to that specific shortcut.
Below is the correct way of running cmd.exe as Admin on Windows 8 and Windows 10
On your keyboard press windows key and X then select Command Prompt (Admin) from the list.
Alternatively right click on the start button and select the above mentioned.
This allows your to run cmd.exe as administrator. and you can then run
sfc /SCANNOW
Right-click on the Command Prompt icon and select Run as administrator
On Windows it's easy to run cmd application as administrator:
Right click on cmd icon >> run as administrator`
But I would like to use PhpStorm terminal tool as administrator since I constantly have to execute queries that require administrator role.
When I open:
File >> Settings >> Tools >> Terminal
I can see that it is directly connected to cmd.exe and there are options to be filled:
And I see no checkbox with choice to run it as administrator.
QUESTIONS
Is it even possible?
If yes how do I do it?
Using settings or other way?
There are no options in the IDE for that at the moment: to run the shell (cmd.exe, powershell.exe etc.) with higher rights.
https://youtrack.jetbrains.com/issue/IDEA-121335 -- watch this ticket (star/vote/comment) to get notified on any progress. Maybe someone will post some possible workarounds there...
Your only option for now (that I'm aware of) is running IDE itself as Administrator -- Process Hacker tool confirms that both the IDE and cmd.exe will be run with elevated rights.
P.S.
For one time execution (or if you need to run IDE as normal user) -- have a look at this question and offered solutions: How to open an elevated cmd using command line for Windows?
I have written a batch file which will call another batch file and delete some files. For this I need to have admin rights. I tried following command...
runas /user:bala#nsc cmd
Enter the password for bala#nsc: xxxxxxx
Even though bala#nsc has admin rights command prompt is getting opened as a simple user rather than administrator.
I guess, I am missing something. Please help me.
Your results aren't what I expected, either. But I've got a few workarounds to suggest.
You could turn off User Account Control.
You could go to Start --> All Programs --> Accessories, then right-click on "Command Prompt" and choose "Run as Administrator."
You could right-click on your batch script and do the same.
You could create a shortcut to either cmd or your batch script on your Desktop, then modify the properties of that shortcut to run as Administrator.
You could add some code to your batch script to check for admin privileges and prompt for escalation if needed.
Turning off UAC would be my choice.
I'm trying to run a batch file as admin. I found that I can use runas command which corresponds sudo command in Linux I think.
I tried
runas /noprofile /user:computername\adminuser "blah.bat start"
But it gives an error, saying :
Logon failure: user account restriction.. (msdos window doesn't allow me to copy anything) is there any way I can run this batch file as admin? Right click doesn't work because I can't include any parameters.
A workaround: You can create a shortcut to the batch file, add a parameter in the shortcut, then right-click to run the shortcut as admin.
Right-click the icon for the command-prompt and choose Run As Administrator. Then run you batch file from that window.
I believe that you can allow or disallow the RunAs command with the registry.
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\policies\Explorer
"HideRunAsVerb"= 1
See Disabling the RunAs Command