Change User

  • Thread starter Thread starter Jesse
  • Start date Start date
J

Jesse

Hi All,

I have been told that it is possible to change the user
that is currently logged on to windows in a CMD prompt
session (ie without logging out and re-entering). I want
to be able to do this as i plan to add user accounts to
the remote domain machine and need to be logged in as an
administrator with privillages on that domain. I need to
do this at the cmd prompt though.

Firstly, is this possible? And secondly, if so, could
anybody let me know how this is done?

Thanks,
Jesse
 
You can run a command (as well as starting another cmd window )as another
user using the RUNAS command:

RUNAS USAGE:

RUNAS [ [/noprofile | /profile] [/env] [/netonly] ]
/user:<UserName> program

RUNAS [ [/noprofile | /profile] [/env] [/netonly] ]
/smartcard [/user:<UserName>] program

/noprofile specifies that the user's profile should not be loaded.
This causes the application to load more quickly, but
can cause some applications to malfunction.
/profile specifies that the user's profile should be loaded.
This is the default.
/env to use current environment instead of user's.
/netonly use if the credentials specified are for remote
access only.
/savecred to use credentials previously saved by the user.
This option is not available on Windows XP Home Edition
and will be ignored.
/smartcard use if the credentials are to be supplied from a
smartcard.
/user <UserName> should be in form USER@DOMAIN or DOMAIN\USER
program command line for EXE. See below for examples

Examples:
runas /noprofile /user:mymachine\administrator cmd
runas /profile /env /user:mydomain\admin "mmc %windir%\system32\dsa.msc"
runas /env /user:[email protected] "notepad \"my file.txt\""

NOTE: Enter user's password only when prompted.
NOTE: USER@DOMAIN is not compatible with /netonly.
NOTE: /profile is not compatible with /netonly.
 
Thanks for the response.

When i use the runas command another prompt window opens
up after running my program. The problem is that the box
asks for a password for the username supplied in the runas
command. Is there any way to make this automatic - ie
pass in or script the password entry?

Jesse
-----Original Message-----
You can run a command (as well as starting another cmd window )as another
user using the RUNAS command:

RUNAS USAGE:

RUNAS [ [/noprofile | /profile] [/env] [/netonly] ]
/user:<UserName> program

RUNAS [ [/noprofile | /profile] [/env] [/netonly] ]
/smartcard [/user:<UserName>] program

/noprofile specifies that the user's profile should not be loaded.
This causes the application to load more quickly, but
can cause some applications to malfunction.
/profile specifies that the user's profile should be loaded.
This is the default.
/env to use current environment instead of user's.
/netonly use if the credentials specified are for remote
access only.
/savecred to use credentials previously saved by the user.
This option is not available on Windows XP Home Edition
and will be ignored.
/smartcard use if the credentials are to be supplied from a
smartcard.
/user <UserName> should be in form USER@DOMAIN or DOMAIN\USER
program command line for EXE. See below for examples
Examples:
runas /noprofile /user:mymachine\administrator cmd
runas /profile /env /user:mydomain\admin "mmc %windir% \system32\dsa.msc"
runas /env /user:[email protected] "notepad
\"my file.txt\""

NOTE: Enter user's password only when prompted.
NOTE: USER@DOMAIN is not compatible with /netonly.
NOTE: /profile is not compatible with /netonly.

Hi All,

I have been told that it is possible to change the user
that is currently logged on to windows in a CMD prompt
session (ie without logging out and re-entering). I want
to be able to do this as i plan to add user accounts to
the remote domain machine and need to be logged in as an
administrator with privillages on that domain. I need to
do this at the cmd prompt though.

Firstly, is this possible? And secondly, if so, could
anybody let me know how this is done?

Thanks,
Jesse


.
 
Jesse said:
Thanks for the response.

When i use the runas command another prompt window opens
up after running my program. The problem is that the box
asks for a password for the username supplied in the runas
command. Is there any way to make this automatic - ie
pass in or script the password entry?
Hi

You might get something to work using a Runas wrapper utility or
similar, take a look here:

http://groups.google.com/[email protected]

Another one that is not menioned above:

LSrunas/LSrunasE (the latter with password encryption)
http://www.linkselection.com/lsrunas.asp
 
You can also check out cpau, at http://www.joeware.net/win32


--
Joe Richards Microsoft MVP Windows Server Directory Services
www.joeware.net


Thanks for the response.

When i use the runas command another prompt window opens
up after running my program. The problem is that the box
asks for a password for the username supplied in the runas
command. Is there any way to make this automatic - ie
pass in or script the password entry?

Jesse

-----Original Message-----
You can run a command (as well as starting another cmd

window )as another
user using the RUNAS command:

RUNAS USAGE:

RUNAS [ [/noprofile | /profile] [/env] [/netonly] ]
/user:<UserName> program

RUNAS [ [/noprofile | /profile] [/env] [/netonly] ]
/smartcard [/user:<UserName>] program

/noprofile specifies that the user's profile

should not be loaded.
This causes the application to load

more quickly, but
can cause some applications to
malfunction.

/profile specifies that the user's profile

should be loaded.
This is the default.
/env to use current environment instead

of user's.
/netonly use if the credentials specified are

for remote
access only.
/savecred to use credentials previously saved

by the user.
This option is not available on

Windows XP Home Edition
and will be ignored.
/smartcard use if the credentials are to be

supplied from a
smartcard.
/user <UserName> should be in form

USER@DOMAIN or DOMAIN\USER
program command line for EXE. See below for
examples

\system32\dsa.msc"

\"my file.txt\""
NOTE: Enter user's password only when prompted.
NOTE: USER@DOMAIN is not compatible with /netonly.
NOTE: /profile is not compatible with /netonly.

message

want

to



.
 
Note that there is a danger in just sending an encrypted password. This was
something I was fighting with myself when writing the functionality into CPAU.
The issue is that if you place that into a batch file that a normal user can
read, they can simply copy what you have done and change the command line.

joe
 
You can have passwords in your batch file and then convert
your batch file to exe or .com using bat2exe.
-Nimit
 
Nimit Mehta said:
You can have passwords in your batch file and then convert
your batch file to exe or .com using bat2exe.

Even id the resulting .exe file works -- which they often do not -- I
think you'll find that the actual batch commands are stored in the .exe
file in plain text, easily viewable with Notepad or any other text editor.
 
Back
Top