Google Answers Logo
View Question
 
Q: Log off and on and switching users from the command prompt. ( No Answer,   7 Comments )
Question  
Subject: Log off and on and switching users from the command prompt.
Category: Computers > Programming
Asked by: compuplus-ga
List Price: $25.00
Posted: 08 Apr 2003 10:56 PDT
Expires: 08 May 2003 10:56 PDT
Question ID: 187755
How can I log off one user and log on to another user from the command prompt.
Also how can I switch from one user to another from the command prompt.
I'm using windows XP.
Answer  
There is no answer at this time.

Comments  
Subject: Re: Log off and on and switching users from the command prompt.
From: deadlychiapet-ga on 08 Apr 2003 16:24 PDT
 
Hi there,

Logging off from the command prompt is simple. The command is:
logoff [/n] [/f]
Where /n prevents a confirmation dialog box from coming up, and /f
suppreses dialog boxes from applications asking you to save your data.
See the following website for more information on that:
http://www.winnetmag.com/Articles/Index.cfm?ArticleID=9676.
Unfortunately, I don't think there's a way to log on or switch users
from the command prompt (but I could be wrong, it's been known to
happen =)).

Deadlychiapet-ga
Subject: Re: Log off and on and switching users from the command prompt.
From: compuplus-ga on 08 Apr 2003 17:27 PDT
 
Thank you again for taking the time to answer.
if it can't be done from the command line can it be done in a VB application?
Subject: Re: Log off and on and switching users from the command prompt.
From: raviaw-ga on 25 May 2003 07:49 PDT
 
You can perform a logoff using the Windows API ExitWindowsEx.

To make an automatic logon, you must have auto-logon enabled. TweakUI
makes this for you, but requires user-interation. You can get the
regmon utility from www.sysinternals.com to see what this app does
when saving the autologon info. TweakUI can be obtained in
Microsoft.com site.

Important: Don't forget to delete the autologon info on next user
logon
Subject: Re: Log off and on and switching users from the command prompt.
From: compuplus-ga on 25 May 2003 10:31 PDT
 
hi raviaw-ga 

I want to log off change users and then log back on from the command
prompt without having to press OK.
Subject: Re: Log off and on and switching users from the command prompt.
From: raviaw-ga on 02 Jun 2003 19:44 PDT
 
Sorry for my lack in time.
My E-Mail is raviaw@uol.com.br

To configure auto-logon:

REGEDIT4

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows
NT\CurrentVersion\Winlogon]

"DefaultUserName"="User"
"DefaultDomainName"="Domain"
"AutoAdminLogon"="1"
"DefaultPassword"="Password" 

To disable auto-logon, change the value of AutoAdminLogon to 0 (zero)
You can do this by adding a value to the RunOnce regkey under
HKLM\Software\Microsoft\Windows\CurrentVersion. Create a .cmd file (or
.bat, it's the same thing), and then make a call to regedit passing as
the paramater /s (for a silent call) and the name of the .reg file
with the new settings. You can do the same thing for the keys above
(try to save then to a file and load them). You must be an
administrator to configure the related keys.

Good luck.
Subject: Re: Log off and on and switching users from the command prompt.
From: compuplus-ga on 03 Jun 2003 08:08 PDT
 
Hi raviaw-ga 

Thanks for taking time to answer my question.

I tried what you wrote many times. it only works when restarting the
computer. I need it to work to log in put the new name in and log
right back in without prompt. something like switch user but log off
log on.
Subject: Re: Log off and on and switching users from the command prompt.
From: raviaw-ga on 03 Jun 2003 17:37 PDT
 
Won't be better to you try to run an application as another user?

There's an API called CreateProcessWithLogonW (UNICODE) that creates a
process with other user instance. You just pass the username and
password.

As seen on this page:
http://www.microsoft.com/windows2000/techinfo/reskit/en-us/default.asp?url=/windows2000/techinfo/reskit/en-us/regentry/12315.asp,
the need for reboot is documented at Microsoft.com site.

There are many ways to force an process to run with other users:
there's the runas application in Windows 2000 (runas /?)
you can create a service with the user instance - or you can create a
service that can call the LogonUser function to taken a user token,
and then use this.
or - as last alternative - you can create a DLL that replaces the
Microsoft GINA (MSGINA.dll) with another from your own. The GINA DLL
is responsible for taking user information and perform the logon, when
you press CTRL+ALT+DEL all the screens that appears are from the GINA.

Good luck.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy