Command line argument for running as another user on Windows?

1,855

Solution 1

Is this what you are looking for?

RUNAS

Execute a program under a different user account.

Syntax
      RUNAS [/profile] [/env] [/netonly] /user:user Program

Key
   /profile   Option to load the user's profile (registry)
   /env       Use current environment instead of user's.
   /netonly   Use the credentials specified only for remote connections.
   /user      Username in form USER@DOMAIN or DOMAIN\USER
              (USER@DOMAIN is not compatible with /netonly)
   Program    The command to execute

Enter the password when prompted.

When you start a program with RunAs /netonly, the program will execute on your local computer as the user you are currently logged on as, but any connections to other computers on the network will be made using the user account specified.

Without /netonly everything will run under the user account specified.

Solution 2

In the shortcut target space:

C:\Windows\System32\runas.exe /profile /user:COMPUTERNAME_04\administrator C:\totalcmd\TOTALCMD64.EXE
Share:
1,855
Neo
Author by

Neo

Updated on September 17, 2022

Comments

  • Neo
    Neo over 1 year

    I am trying to incorporate CSS before content. I want to put info icon (i), which is "\e608"

    #securityCodeLink:before {
        content: "\e608";
    }
    

    The output looks like this

    e608

    But if i try with 2701 or something like that

    #securityCodeLink:before {
        content: "\2701";
    }
    

    It works perfectly fine.

    2701

    Can any one tell me why is this and how can i fix this?

    • Jeyarathnem Jeyachanthuru
      Jeyarathnem Jeyachanthuru about 10 years
      Did you add the font-family?
    • Neo
      Neo about 10 years
      Yes i have font family.
    • Neo
      Neo about 10 years
      font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
    • Jeyarathnem Jeyachanthuru
      Jeyarathnem Jeyachanthuru about 10 years
      so Helvetica New dosent have this symbol right?
  • kellogs
    kellogs over 13 years
    I believe 'runas' is a shell command. I need the command to be 'myexe.exe' followed by some argument which would make it run under different credentials. Any other hints ?
  • Stanley Williams
    Stanley Williams over 13 years
    Any modifier that comes after the command has to be built into the program. An example is iexplore.exe /k This opens Internet Explorer in kiosk mode and is built into the executable. Unless you write a script which executes the shell command with the program if you pass a modifier to the script like myscript.bat that runs myfile.exe normally but myscript.bat /another that runs myfile.exe through the shell command as another user.
  • kellogs
    kellogs over 13 years
    You are right. no way around it I guess. Thank you
  • barlop
    barlop over 11 years
    very silly @kellogs obviously you cannot say there is no way around it. In fact there most definitely is a way around it. I once ran a script that did runas and wrote a password, and there is a program that will run a cmd shell hidden. So it is possible in theory, as a combined solution. The program that runs things hidden is HSTART ntwind.com/software/hstart.html
  • Tim
    Tim over 10 years
    I think the OP wants to have the program executed as another user (e.g. the administrator, this is done as you propose) and then have the program calling another command/program that is run as the original user. So you answer a question that is not asked.