Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm a member of administrators group on Windows 7. I need to run foo.exe from a Cmd or Powershell. The exe file requires elevation to work but the elevation is not specified in its manifest.

Usually I have to do start . to open Explorer, right-click the exe and select Run as administrator.

Is there an easier way? I'm not going to turn UAC off, I don't want to have the password remembered passwords or to avoid the prompt. I just want to avoid the need to launch the Explorer window.

I'm a member of administrators group. I don't want to run as another user, I only want to see the passwordless UAC prompt I see when I do myself when right clicking in Explorer, but without opening the explorer, running third-party tools, disabling UAC, ability to do the same from scripts or remembering credentials.

I just want to invoke the usual UAC prompt without an intermediate step.

To clarify, I want the following sequence:

  1. Windows 7, UAC on, I'm in administrators group, UAC prompt is set to answer yes/no.

  2. Open a non-elevated command prompt and navigate to a deep folder and do other tasks.

  3. I run 'elevate-command-sequence foo.exe' and an UAC prompt opens exactly the same way it opens when I right-click in Explorer. Current directory for foo.exe is set to the deep folder I'm in.

I wonder if such elevate-command-sequence exists in cmd or powershell out of the box.

share|improve this question
1  
You can use the runas and provide an Administrator account and the password to do this. An example would of the command is runas /user:"Administrator" –  Ramhound Sep 11 '13 at 13:36
    
That was answered zillion times and it's not what I want. I'm a member of administrators group. I don't want to run as another user, I only want to see the passwordless UAC prompt I see when I do myself when right clicking in Explorer, but without opening the explorer, running third-party tools, disabling UAC, ability to do the same from scripts or remembering credentials. I just want to invoke the usual UAC prompt without an intermediate step. –  nponeccop Sep 11 '13 at 13:45
1  
If its not what you want clarify your question. I suggest you modify the manifest file. I highly suspect if you runas the same profile your using you won't get a password propmpt. Since you were sort of rude to me I don't plan on returning to this question. –  Ramhound Sep 11 '13 at 13:53
    
I only wanted to mention the long list of other scenarios I have read about to ensure the audience that I did search for existing answers. I'm sorry for sounding rude, insulting was not my intent. –  nponeccop Sep 11 '13 at 14:04

2 Answers 2

Maybe this Group policy Setting Change May help you :

  1. Start-->run-->gpedit.msc

  2. Navigate to Computer Configuration --> Policies-->Windows Settings-->Security Settings -->Local Policies-->Security Options

enter image description here

3.Change the behavior of elevation prompt for administrator (you can derive as you wish)

Restart the computer to make changes effect

share|improve this answer
    
I'd qualify this as 'disabling UAC'. It's not what I want. I want the prompt to remain in place. –  nponeccop Sep 11 '13 at 14:11
1  
@nponeccop - You can't have everything in life. UAC is designed in a specific, elevation of the process, any user except the one that is currently logged will require a password if the account itself has a password. –  Ramhound Sep 11 '13 at 14:19
    
It's exactly what I want. I'm the user who logged in, and I'm in admin group. If it asks me for my pass in UAC prompt or prompts yes/no it's not a problem. –  nponeccop Sep 11 '13 at 14:22

The command prompt can not natively launch elevated applications if itself was not launched in a elevated state. It sucks, but it is just part of windows behavior.

If you want to work around it you must use a 3rd party tool that will launch the program elevated for you. From some quick googling I found ELE, this will let you run a program in a elevated state from a non elevated command prompt (after a UAC pop up of course)

c:\>ele foo.exe  

I am sure there are a million more programs that do this, heck I could write one in C# here in this answer.

namespace Sandbox_Console
{
    public class Program
    {

        private static void Main(string[] args)
        {
            Process newProcess = new Process();
            newProcess.StartInfo.Verb = "runas";
            newProcess.StartInfo.WorkingDirectory = Environment.CurrentDirectory;
            newProcess.StartInfo.FileName = args[0];
            newProcess.StartInfo.Arguments = String.Join(" ", args, 1, args.Length - 1);
            newProcess.Start();
        }
    }
}

Now that code is very fragile and it can not handle stuff like spaces in arguments right now but it would not be difficult to add.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.