6
How can I elevate a open cmd window such that it has administrator rights as it would have if i would start it with "run as administrator"?
6
How can I elevate a open cmd window such that it has administrator rights as it would have if i would start it with "run as administrator"?
3
You can use the runas
command to elevate individual commands, and you can use runas
to start a new shell, but you cannot elevate the current shell.
1
I have a hard time believing that this would be possible. Even the example by Microsoft restarts the process to achieve elevation.
This is correct. A process can only be elevated at startup. – surfasb – 2012-03-10T02:47:08.033
hmmm - can I use this somehow together with "reg" to make changes to the registry from an unelevated cmd promt? the problem is, that at the moment i can't start elevated apps because i messed something up in the registry, but i need an elevated cmd to make use of "reg", and also regedit requires to be run elevated – Mat – 2012-03-09T12:45:52.707
3You should specify that in your question! Entirely different solution! But that said, you can try using it to elevate reg. If your problem is that you're not receiving any elevation prompts, it won't work. You'll instead need to use a Win7 install or Startup Repair disc to load and edit what you need to edit. – EKW – 2012-03-09T12:53:13.883
I think using RunAs will start a new process with elevated privileges, not elevate the current process. But I'm with EKW, you need to boot to a repair disk to fix this. – uSlackr – 2012-03-09T13:13:38.947
@uSlackr You're correct,
runas
will open a new process. But, in some cases, elevation from Explorer can be broken without affecting elevation from a command prompt. Similar issues can show up with InstallShield. – EKW – 2012-03-09T13:15:49.050It wil be interesting to see the fix for this. I've never heard of it before. – uSlackr – 2012-03-09T13:35:09.107
Runas does not elevate commands.
runas /user:administrator cmd
will still fire off UAC. This is a misconception, because the builtin Admin account has autoelevate enabled. – surfasb – 2012-03-10T02:46:17.350runas
runs as another user. If you userunas
to run something as Admin, it will call UAC in order to elevate, which is the desired outcome. UAC failing when called from Explorer doesn't automatically mean UAC will fail no matter what the calling process. – EKW – 2012-03-10T06:57:25.360