Link to home
Start Free TrialLog in
Avatar of nicolashurtado
nicolashurtadoFlag for United States of America

asked on

Default User RunOnce after Sysprep in Windows 7


What I need to do is create an image and within that image I'd like to setup a script that will runonce for all new users after it's applied to the target PCs.

The problem is that I also need to do these changes before making the image. What I'm considering is to use the copyprofile setting in my sysprep answer file to propagate the Default User Profile first and then I'm considering to make a batch file to edit the registry. I can call this batch file in the sysprep file in Pass7. I'm not 100% sure that this will accomplish what I want though.

Has anyone had success with editing the Default User Hive @ %HIVE%\Software\Microsoft\Windows\CurrentVersion\Runonce post-sysprep with a sysprep file?

If it won't work what are my other options?
Avatar of Hossy
Hossy

In all the images I've created, I've always written a series of BAT/REG files to modify the system as needed after sysprep.  I've never tried RunOnce on the default user before, but it should be easy enough to try on a VM -- shouldn't take more than an hour.  Remember to take snapshots so you can quickly try different scenarios.
Avatar of nicolashurtado

ASKER

This is what I'm thinking.


::****** File:DefaultUserEdit.bat
:: ***** Configure Default User
:: *** Load Default User hive
reg load "hku\Test" "%USERPROFILE%\..\Default User\NTUSER.DAT"
:: *** Disable Desktop Cleanup
reg add "hku\Test\Software\Microsoft\Windows\CurrentVersion\Runonce" /v test.bat /t REG_SZ /d c:\test.bat /f
:: *** Unload Default User hive
reg unload "hku\Test"
Why go through the process of loading?

The default profile is always loaded at: HKU\.DEFAULT

So just do:

reg add "hku\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\Runonce" /v test.bat /t REG_SZ /d c:\test.bat /f
Last I checked there isn't a RunOnce under .default only Run and that's not going to work for my batch file
No, there isn't, but you can create it.

The other option is to place it under Run and have your batch file delete itself under HKCU\...\Run once it's run successfully.  Basically, that would cause it to run everytime until it succeeds.
Well the situation calls for each user who logs into the pc to have certain settings enabled by default which means I can't delete the file itself.


Have you created  hku\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\Runonce and it worked?
I didn't mean for the BAT to delete the BAT, I meant for the BAT to delete the BAT's Run entry under HKEY_CURRENT_USER\...\Run

I can't say with 100% certainty that I've done it before...I think I have, but I don't remember what I had for dinner last week so.... :-)
ASKER CERTIFIED SOLUTION
Avatar of nicolashurtado
nicolashurtado
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
not 100% happy to have to run sysprep twice