login - Windows 7 automatically logs out when logging in

17
2013-11
  • Canadian Luke

    A Windows 7 HP x64 computer is set to automatically log in (no password), but once it starts logging in, it starts to load the desktop after the welcome screen, but before icons or background images are loaded, it goes to the Welcome screen saying 'Logging Off'. I can log in with Safe Mode, and I ran a couple different virus scans, with no detections. I also tried checking the userinit.exe file in System32 (as suggested by MANY users for Windows XP), but it's the same version as a working system. I also checked the registry under HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon for the SHELL and UserInit values, but they look normal. I tried to disable all startup items (through MSCONFIG) to select Diagnostic boot, but then I get a blue screen about the video driver not loading. Any other ideas?

    EDIT I created a new user, and it could log in no problems. I am thinking it's the NTUSER.DAT file. I just renamed it to NTUSER.DAT.old, then tried logging in as the problem user. I could log in, but as a TEMP profile. His profile folder is now C:\Users\TEMP, and his old folder is still accessible but in the wrong location.

    EDIT 2 I can't seem to turn off the TEMP profile, so I'm open to other suggestions. Copying the folders (i.e. Documents, Music, etc) does not work, as it creates an additional TEMP.000 then TEMP.001 folder each time the user logs in.

  • Answers
  • surfasb

    The solution is simple: abandon ship.

    His old profile is shot. Especially if it is as elusive of a problem as this, you have no idea what else is broken even if you manage to get logged in. Who knows how long it will be before you are troubleshooting Yet Another Profile Issue.

    Use the new profile. Drag and drop his data files. Some programs may have to be reinstalled (if they were installed to the current user, rather than All Users).

  • Indrek

    You have to delete the registry key related to the user as per below:

    1. Restart the computer and login as a Local Admin or another domain user.
    2. Rename: C:\Users\%username%
    3. Export (just as a backup in case you need it) and then delete the following registry key:
      HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WindowsNT\CurrentVersion\ProfileList
      (Look through each Profile key under this reg key and view the ProfileImagePath value to find which key is related to which user).
    4. Logout and login as the original user and it will create a new profile for them.

    If you do not delete the registry key it will continually give a temporary profile to that user infinitely or until you rename their C:\Users\%username% folder back.


  • Related Question

    login - Automatically run a script when I log on to Windows
  • Hallgrim

    How can I automatically run a script when I log on to Windows?

    I'd like to run this whenever I log into my computer:

    echo %USERNAME% logged on at %DATE% %TIME% >> log.txt
    

    A bonus would be to be able to run the same script whenever I unlock the screen saver as well.


  • Related Answers
  • slhck

    If you already have a script:

    To assign a logon script to a user or group

    • Open Computer Management.
    • In the console tree, click Users.

    Where? System Tools/Local Users and Groups/Users

    • Double-click the user to which you want to assign a logon script.
    • Click the Profile tab.
    • In the Logon script field, enter the path and name of the logon script you want to assign to that user, and then click OK.

    Else here's a handy "HowTo" from Microsoft

    Creating logon scripts

    You can use logon scripts to assign tasks that will be performed when a user logs on to a particular computer. The scripts can carry out operating system commands, set system environment variables, and call other scripts or executable programs. The Windows Server 2003 family supports two scripting environments: the command processor runs files containing batch language commands, and Windows Script Host (WSH) runs files containing Microsoft Visual Basic Scripting Edition (VBScript) or Jscript commands. You can use a text editor to create logon scripts. Some tasks commonly performed by logon scripts include:

    • Mapping network drives.
    • Installing and setting a user's default printer.
    • Collecting computer system information.
    • Updating virus signatures.
    • Updating software.
    • The following example logon script contains VBScript commands that use Active Directory
    • Service Interfaces (ADSI) to perform three common tasks based on a user's group membership:

    It maps the H: drive to the home directory of the user by calling the WSH Network object's MapNetworkDrive method in combination with the WSH Network object's UserName property. It uses the ADSI IADsADSystemInfo object to obtain the current user's distinguished name, which in turn is used to connect to the corresponding user object in Active Directory. Once the connection is established, the list of groups the user is a member of is retrieved by using the user's memberOf attribute. The multivalued list of group names is joined into a single string by using VBScript's Join function to make it easier to search for target group names.

    If the current user is a member of one of the three groups defined at the top of the script, then the script maps the user's G: drive to the group shared drive, and sets the user's default printer to be the group printer. To create an example logon script

    • Open Notepad.
    • Copy and paste, or type, the following:

      Const ENGINEERING_GROUP     = "cn=engineering"
      Const FINANCE_GROUP         = "cn=finance"
      Const HUMAN_RESOURCES_GROUP = "cn=human resources"
      
      Set wshNetwork = CreateObject("WScript.Network")
      wshNetwork.MapNetworkDrive "h:",
      "\\FileServer\Users\" & wshNetwork.UserName
      
      Set ADSysInfo = CreateObject("ADSystemInfo")
      Set CurrentUser = GetObject("LDAP://" &
      ADSysInfo.UserName)
      strGroups = LCase(Join(CurrentUser.MemberOf))
      
      If InStr(strGroups, ENGINEERING_GROUP) Then
      
          wshNetwork.MapNetworkDrive "g:",
          "\\FileServer\Engineering\"
          wshNetwork.AddWindowsPrinterConnection
          "\\PrintServer\EngLaser"
          wshNetwork.AddWindowsPrinterConnection
          "\\PrintServer\Plotter"
          wshNetWork.SetDefaultPrinter
          "\\PrintServer\EngLaser"
      
      ElseIf InStr(strGroups, FINANCE_GROUP) Then
      
          wshNetwork.MapNetworkDrive "g:",
          "\\FileServer\Finance\"
          wshNetwork.AddWindowsPrinterConnection
          "\\PrintServer\FinLaser"
          wshNetWork.SetDefaultPrinter
          "\\PrintServer\FinLaser"
      
      ElseIf InStr(strGroups, HUMAN_RESOURCES_GROUP) Then
      
          wshNetwork.MapNetworkDrive "g:",
          "\\FileServer\Human Resources\"
          wshNetwork.AddWindowsPrinterConnection
          "\\PrintServer\HrLaser"
          wshNetWork.SetDefaultPrinter
          "\\PrintServer\HrLaser"
      
      End If
      
    • On the File menu, click Save As.

    • In Save in, click the directory that corresponds to the domain controller's Netlogon shared folder (usually SystemRoot\SYSVOL\Sysvol\DomainName\Scripts where DomainName is the domain's fully qualified domain name).
    • In Save as type, click All Files.
    • In File name, type a file name, followed by .vbs, and then click Save. WSH uses the .vbs extension to identify files that contain VBScript commands.
  • Bruce McLeod

    The simplest way I can think of would be to put this in a .bat file in your startup folder.

    A more complicated way would be to add the batch file to the registry in the

    HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run
    

    registry key.

  • Axxmasterr

    A good alternate method is to create a batch file with the commands you want to run in them. Next you will specify in the policy editor on the machine that it run a login script as part of the login process. A quick note is this option is only available on XP Pro and not the home version.

    Group Policy Editor Tutorial Here

  • techie007

    Anyone know if this can be used to run when the screen is locked/unlocked as well?

    There is a way for Windows 7 and/or Windows Server 2008.

    Use Task Scheduler, create new basic task, as the Trigger use "When I log on".