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.?
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
Summary for what I did to resolve this issue:
- I've created a script in
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
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon in the registry setting the value to
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
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
- In the
Generaltab, fill out a descriptive name and, optionally, a description for your task.
- In the
Begin the taskto
At log on. Check the
Specific usercombobox, make sure your username is selected (you can use
Any userif 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 forcheckbox and type in the time (e.g.
30 seconds). Click ok to create the trigger.
- In the
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.exeas the program, and
C:\path\to\script.py some_argumentsas arguments. Click ok to create the action.
- In the
Conditionstab, you probably want to uncheck the
Start the task only if the computer is on AC power.
- In the
Settingstab, 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.
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.
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")!
You can also just create a task using task scheduler and setting the trigger to run the script at logon.
You still use UI to configure logon script in Windows 7
"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