Monday, 28 April 2014

Run a Program as Different User

Description:

   Running a Program as Different User is one of the easiest way to Impersonate a Program/Application with some other user's privilege. For every administrators, this would be the common need either for testing or to impersonate different user privilege. In this article, I am going to write and explain about how to Run a Program as Different User and how to Run a Program as System account.

Summary:


Run a Program as Different User

You can execute a program under a different user account by using the command line tool RunAs. Use the below command to open new CMD window under different user
C:\> RunAs /user:rtest cmd
Run program under Different User

You will prompted to enter password when you execute this command. type password and click 'Enter' to open new cmd window under the different user 'rtest'.

Run Program as Different User

Run a Program as System Account

You can execute or run a program under local system account by using sysinternals's Psexec utility. you can download at http://technet.microsoft.com/en-us/sysinternals/bb897553. You can use the -s switch to run a program as the system account. The following example shows how to start a cmd.exe session under the system account:
C:\PSTools> PsExec -s cmd.exe

PsExec v2.1 - Execute processes remotely
Copyright (C) 2001-2013 Mark Russinovich
Sysinternals - www.sysinternals.com

Microsoft Windows [Version 6.1.7600]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Windows\system32>whoami
nt authority\system

C:\Windows\system32>exit
cmd.exe exited on HP-PC with error code 0.
Run as Local System Account

Once you have completed the work you can revert to current user by executing exit command.

Run a Program as Different Domain User for Remote Connections

You can execute a program under different domain user for remote connections by using the parameter /netonly in RunAs command. Use the below command to open new CMD window under different domain user
RunAs /netonly  /user:work2008\RDtest cmd
Run as Different Domain User for Remote Connections

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.



Thanks,
Morgan
Software Developer

Advertisements
Advertisements

No comments:

Post a Comment