Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

On Windows 7 Professional one can right-click the user in the Computer Management's Local Users and Groups to set the Logon script on the Profile tab. Unfortunately, Windows 7 Home Premium does not (seem to) have the Local Users and Groups in the Computer Management. How to configure the logon script on Windows 7 Home Premium.?

share|improve this question
1  
In a standalone system, is there any advantage in configuring a logon script over just putting it in the Startup folder? – grawity Mar 21 '11 at 9:15
2  
The advantage is that the script will be loaded very early, e.g. before launching other applications. This is very useful to mount encrypted partitions. – Mike L. Mar 21 '11 at 12:30

You're right, this MMC snap-in is disabled unless you have at least Windows 7 (or Vista) Professional.

You should be able to configure user properties using the net user command:

net user UserName /scriptpath:logon.bat

The script location:

Local logon scripts must be stored in a shared folder — or subfolders of the shared folder — named Netlogon. If this folder does not exist by default, you must create it. To specify a logon script that is stored in a subfolder of the Netlogon folder, precede the file name with the relative path to that folder. For example, to assign the Startup.bat logon script that is stored in \ComputerName\Netlogon\FolderName to a local user, in Logon script type FolderName\Startup.bat

share|improve this answer
    
Where is the directory "\ComputerName\Netlogon\FolderName" located? – Mike L. Mar 21 '11 at 12:29
1  
@mklhmnn: Wherever you want it. The example given is for a domain, with one server holding all scripts; domain controllers have a share \\servername\Netlogon for this purpose. If you give a relative path, it will be looked for in the DC's Netlogon share. (Behavior unknown for standalone systems.) But you can give an absolute path, e.g. C:\WINDOWS\Misc\logon.cmd. – grawity Mar 21 '11 at 12:37
1  
Wherever you want - for example, create a folder c:\logon and share it as Netlogon. – Siim K Mar 21 '11 at 12:38
1  
@grawity using /scriptpath:path You can't use an absolute path. – Hanan N. Dec 15 '14 at 11:11
up vote 8 down vote accepted

Summary for what I did to resolve this issue:

  • I've created a script in C:\Windows\System32\repl\import\scripts\<username>.bat
  • invoked net user <username> /scriptpath:<username>.bat

Because Windows 7 Home did not wait until this script had been finished and continued to load other applications, I also needed to create a DWORD entry named RunLogonScriptSync at HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon in the registry setting the value to 1.

share|improve this answer
1  
Is there a way to reverse this command? In other words turn off a script you assigned to a user profile? – Radical924 Jan 25 '15 at 10:46

I’m using Win 7 Premium Home on a standalone system and wanted to run a logon script to mount an encrypted volume. Searching the net gave only complicated results (gpedit, registry update). My solution is very simple: I created on C: a folder (with a name whatever you want) and put my script into it. This folder must be shared with the share name “Netlogon” It works! At least on my local system.

share|improve this answer

System error 5 has occurred.

Access is denied.

If you get an error like this when running the net user command, make sure you run CMD as adminisitrator (use right click and select "Run as administrator")!

share|improve this answer

You can also just create a task using task scheduler and setting the trigger to run the script at logon.

share|improve this answer
    
This answer could be improved by including procedures and steps involved to configure a script to run in task scheduler. – Will.Beninger May 23 '14 at 1:23

The accepted answer is the way to do it, if you want your script running early in the system startup, or need the script to run synchronously - that is, the normal logon process will continue only after your script has completed (watch out, it can slow down logon, use it only if you need it).

Note: I'm not sure if the scripts mentioned above can be an .exe file or not, but in the method I will describe any executable can be used.

Another way to do, which has some extra flexibility, is using the Task Scheduler. From the start menu, type Task Scheduler and run it (or run taskschd.msc from Run dialog or a shell). Select Task Scheduler Library in the tree view. If you want, you can create a special subfolder for your programs, but this is not necessary. Click Create Basic Task... (wizard) or Create Task... in the Actions panel on the right side.

I will explain how to use Create Task....

  • In the General tab, fill out a descriptive name and, optionally, a description for your task.
  • In the Triggers tab, click New..., set Begin the task to At log on. Check the Specific user combobox, make sure your username is selected (you can use Any user if you want the program to run when any user logs in). If you don't want your script to slow down the log in process, you can choose to run it after a delay - click Delay task for checkbox and type in the time (e.g. 30 seconds). Click ok to create the trigger.
  • In the Actions tab, click New..., choose your program (or script) using Browse... or type in the full path into Program\program. If the program is in your %Path%, you can just use program. You may specify any arguments to pass to the program in Add arguments. You may specify the working directory for the program in Start in. You can use any type of script the local computer supports; if a script type is not registered with Windows, you can still run it by specifying the script interpreter as the program. E.g. use C:\path\to\python.exe as the program, and C:\path\to\script.py some_arguments as arguments. Click ok to create the action.
  • In the Conditions tab, you probably want to uncheck the Start the task only if the computer is on AC power.
  • In the Settings tab, there is no need to change anything.

Click ok to create the scheduled task. If you want to edit it later, just select Task Scheduler Library in the tree view, find your task in the list (at top part of the window) and double-click the task.

See the Task Scheduler reference for more information.

share|improve this answer

You still use UI to configure logon script in Windows 7

Open "Control Panel" -> "User Accounts" -> "User Accounts" -> "Manage User Accounts" -> "Advanced" -> "Advanced" to access "Local Users and Groups (Local)" MMC snap-in.

or just launch from cmd shell: mmc.exe %SystemRoot%\system32\lusrmgr.msc computername=localmachine

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .