superblades Posted December 7, 2005 Posted December 7, 2005 Is there a way of having a registry key to run once for all users, e.g. every time a user logs onto a pc for the first time it runs a batch file?fred bloggs logs in, a batch file runs and the next time he logs in it doesnt kick in again, john smith logs in on the same computer for the first time and it kicks in the run once to run the batch file?Cheerssuperblades
MHz Posted December 7, 2005 Posted December 7, 2005 (edited) HKCU\Software\Microsoft\Windows\CurrentVersion\RunOnceWhen an entry is applied when no one is logged on, the entry goes to the HKU\.DEFAULT part of the registry. This allows for the RunOnce operation for each account as each logon happens. An ideal time is from Cmdlines.txt to add the entry into this registry key. Edited December 7, 2005 by MHz
muiz Posted December 8, 2005 Posted December 8, 2005 HKCU\Software\Microsoft\Windows\CurrentVersion\RunOnceWhen an entry is applied when no one is logged on, the entry goes to the HKU\.DEFAULT part of the registry. This allows for the RunOnce operation for each account as each logon happens. An ideal time is from Cmdlines.txt to add the entry into this registry key.So i have to run : HKCU\Software\Microsoft\Windows\CurrentVersion\RunOnce from Cmdlines.txt ?
MHz Posted December 8, 2005 Posted December 8, 2005 So i have to run : HKCU\Software\Microsoft\Windows\CurrentVersion\RunOnce from Cmdlines.txt ?You add an entry into HKCU\Software\Microsoft\Windows\CurrentVersion\RunOnce which will runonce for each user account. This is only achieved when no one is logged on. Cmdlines.txt is a good time to add the entry into registry.btw, run was not mentioned. Hopefully, this explaination is easier to understand.
druiddk Posted December 8, 2005 Posted December 8, 2005 @MHz:Can you make an example of running a .cmd script from the registry RunOnce?Thank you in advance.
MHz Posted December 8, 2005 Posted December 8, 2005 (edited) @MHz:Can you make an example of running a .cmd script from the registry RunOnce?Thank you in advance.This is a basic example:Within your $OEM$ directory, you will need Cmdlines.txt, UserRunOnce.cmd and FirstLogon.cmd.Cmdlines.txt:[COMMANDS]"UserRunOnce.cmd"UserRunOnce.cmd:REM ~ Execute this from Cmdlines.txt within the same directory.REM ~ Requirement is also FirstLogon in same directory.@echo offCopy /y FirstLogon.cmd %SystemRoot%Attrib +RSH %SystemRoot%\FirstLogon.cmdReg Add HKCU\Software\Microsoft\Windows\CurrentVersion\RunOnce /v FirstLogon /d FirstLogon.cmd /fFirstLogon.cmd:@echo offecho this is a test of runonce execution of a cmdfilepause1. Cmdlines.txt will execute at T12 and execute UserRunOnce.cmd.2. UserRunOnce.cmd will copy FirstLogon.cmd to the Windows directory and will hide it with attributes. An entry will be added to the HKCU Runonce key which will execute for each account upon first logon (even accounts created later).3. FirstLogon.cmd has only test code but you can add cleanup commands or other suitable commands for your needs. To simply test, just put UserRunOnce.cmd and FirstLogon.cmd on your desktop and execute UserRunOnce.cmd. Log off and logon. When entering the desktop, you should see FirstLogon.cmd execute from the Windows Directory. Test OK. Go to Run and type del %systemroot%\firstlogon.cmd to remove the file from your Windows directory.Do note: The HKCU RunOnce entry will be redirected to the default user part of the registry when no one is logged on. Edited December 8, 2005 by MHz
druiddk Posted December 8, 2005 Posted December 8, 2005 Thank you so much MHz!This will be VERY usefull
faisalahmed_19 Posted August 9, 2007 Posted August 9, 2007 Great Just looking for the same thing.Thanks a lot
BangBang Posted September 17, 2007 Posted September 17, 2007 So i have to run : HKCU\Software\Microsoft\Windows\CurrentVersion\RunOnce from Cmdlines.txt ?You add an entry into HKCU\Software\Microsoft\Windows\CurrentVersion\RunOnce which will runonce for each user account. This is only achieved when no one is logged on. Cmdlines.txt is a good time to add the entry into registry.btw, run was not mentioned. Hopefully, this explaination is easier to understand. Hi there!I'm searching for the RunOnce Key for every new and every existing user on a machine. After an installation there has to be some user-specific work to be done. So, I found this post. Great so far! But here's the problem: Mhz wrote "This is only achieved when no one is logged on.". How do I achieve this? In a XP-new-installation I'm using cmdlines-txt for this, but how to when the computer ist ready installed?Thanks a lot, BangBang
silacomalley Posted September 20, 2007 Posted September 20, 2007 So i have to run : HKCU\Software\Microsoft\Windows\CurrentVersion\RunOnce from Cmdlines.txt ?You add an entry into HKCU\Software\Microsoft\Windows\CurrentVersion\RunOnce which will runonce for each user account. This is only achieved when no one is logged on. Cmdlines.txt is a good time to add the entry into registry.btw, run was not mentioned. Hopefully, this explaination is easier to understand. Hi there!I'm searching for the RunOnce Key for every new and every existing user on a machine. After an installation there has to be some user-specific work to be done. So, I found this post. Great so far! But here's the problem: Mhz wrote "This is only achieved when no one is logged on.". How do I achieve this? In a XP-new-installation I'm using cmdlines-txt for this, but how to when the computer ist ready installed?Thanks a lot, BangBangI believe you will need to change the above example (HKCU\Software\Microsoft\Windows\CurrentVersion\RunOnce) to HKU\.default\Software\Microsoft\Windows\CurrentVersion\RunOnce and run it whilst logged into your regular profile or user account.Try it and see!
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now