Best practice for HKCU adds/app installs needed
#1
Posted 05 November 2012 - 11:43 AM
In the past, I found out some tricks to successfully tinker a customized Windows XP installation including default user profile & system settings, unattended apps (Flash plugin) and paths (winnt.sif).
I'd like to get something similar for Windows 7 x64 sp1. I realized a working autounattend.xml and a $oem$ structure.
This is my current situation:
I can't use autounattend.xml (oobeSystem, FirstLogonCommands...) for running scripts (cmd) that peek into %UserProfile%, because no user exists then.
A RunOnceEx mechanism is gone, so I'm looking for some sort of substitute to execute my scripts at a later date (T+x instead of T-x).
For the nonce, there are shortcuts.cmd (moving & deleting links), userpics.cmd (tidying up "usertiles") and views.cmd (customizing Windows Explorer view via registry).
I don't want to create users, I only adjust the local Administrator account (no domain stuff either). Optionally, I'd also like to initiate a few silent installers (Flash plugin etc.).
There should be several ways to achieve this, like manipulating the file install.wim with DISM or executing scripts afterwards.
Any ideas?
Thanks in advance.
#2
Posted 05 November 2012 - 06:43 PM
http://www.msfn.org/...ost__p__1015918
You can add things to "DEFAULT" user account, if you need to load the "HKCU" you'll find that in NTUSER.DAT in the Users\Default folder.
#3
Posted 06 November 2012 - 01:05 AM
I do most of that with DVD\sources\$OEM$ http://www.msfn.org/...-an-oem-folder/
and RunOnceEx is still alive and well even on Win 8
This post has been edited by maxXPsoft: 06 November 2012 - 01:07 AM
#4
Posted 06 November 2012 - 08:33 AM
@Tripredacus: I'm unsure how to import registry files.
That way would really facilitate things...
@maxXPsoft: Yes, that was my first idea. Actually, I have:
W7DVD
Autounattend.xml
W7DVD\sources\$oem$
$$
$$\setup\scripts ← setupcomplete.cmd, activate.cmd...
$1
$1\a_tmp_folder
$1\Install ← RunOnceEx.cmd, shortcuts.cmd, userpics.cmd, views.cmd...
I commented out the <FirstLogonCommands> section of my Autounattend.xml as setupcomplete.cmd will be processed anyway.
My setupcomplete.cmd contains:
@echo off start /wait C:\Windows\setup\scripts\activate.cmd start /wait C:\Install\RunOnceEx.cmd exit/b 0
And a (basic) RunOnceEx.cmd looks like this:
@echo off SetLocal enableextensions Set K=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx Reg add %K% /f Reg add %K% /f /v Flags /t REG_DWORD /d "20" Reg add %K% /f /v Title /d "Post setup" Reg add %K%\10 /f /ve /d "User Pictures" Reg add %K%\10 /f /v 1 /d "%SystemDrive%\Install\userpics.cmd" Reg add %K%\20 /f /ve /d "Explorer Views & Shortcuts" Reg add %K%\20 /f /v 1 /d "%SystemDrive%\Install\views.cmd" Reg add %K%\20 /f /v 2 /d "%SystemDrive%\Install\shortcuts.cmd" Reg add %K%\30 /f /ve /d "Reboot" Reg add %K%\30 /f /v 1 /d "shutdown.exe /f /r /t 50" REM rundll32.exe iernonce.dll,RunOnceExProcess EndLocal Exit/b 0
However, something has to be wrong, I cannot tell if SetupComplete.cmd or RunOnceEx.cmd is the culprit.
(The RunOnceEx.cmd doesn't look so much differently from what I did in the past.)
My test installation (VMware) stalls with the following screen, not loading Desktop settings for the first time:
bl_scr.png (6.66K)
Number of downloads: 4
I'll comment out the 2nd line of setupcomplete.cmd and try again, I'm quite clueless right now.
This post has been edited by Mikka: 06 November 2012 - 08:41 AM
#5
Posted 06 November 2012 - 09:02 AM
Use Firstlogoncommands but then you wouldn't need the RunOnceEx unless you want to do something on reboot. I delete Install folder with that
REG ADD HKCU\Software\Microsoft\Windows\CurrentVersion\Runonce /V DelInstall /D "Cmd /C RMDIR %systemdrive%\Install\ /S /Q" /f
You could just call your file in Firstlogoncommands and remove the REM rundll32 or add all your files there and run them
<SynchronousCommand wcm:action="add">
<Order>2</Order>
<Description>Running Firstlogon.cmd</Description>
<CommandLine>cmd /C start /wait %systemdrive%\Install\Firstlogon.cmd</CommandLine>
</SynchronousCommand>
This post has been edited by maxXPsoft: 06 November 2012 - 09:08 AM
#6
Posted 06 November 2012 - 01:54 PM
You meant to delete the lines:
Reg add %K%\30 ...
and to re-active/uncomment:
rundll32.exe iernonce.dll,RunOnceExProcess
?
2. The file Autounattend.xml now reads
...
<FirstLogonCommands>
<SynchronousCommand wcm:action="add">
<CommandLine>start /wait %systemdrive%\Windows\setup\scripts\activate.cmd</CommandLine>
<Order>1</Order>
<RequiresUserInput>false</RequiresUserInput>
</SynchronousCommand>
<SynchronousCommand wcm:action="add">
<CommandLine>start /wait %systemdrive%\Install\RunOnceEx.cmd</CommandLine>
<Order>2</Order>
<RequiresUserInput>false</RequiresUserInput>
</SynchronousCommand>
</FirstLogonCommands>
...
The 1st command is correctly processed, but not the 2nd. Don't know why.
Just the setup won't stall this time. RunOnceEx, however, still doesn't work.
#7
Posted 06 November 2012 - 02:21 PM
I meant you could probably run all your cmd's one after another instead of the 1 file doing the RunOnceEx
#8
Posted 09 November 2012 - 03:27 PM
Now I've got a RunOnceEx functionality -- sort of.
It isn't really unattended, which means: The cmd instances stay open, and must be closed manually.
I don't know why, I checked with exit, exit /b 0... and so forth.
My current RunOnceEx.cmd reads:
@echo off SetLocal enableextensions Set K=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx Reg add %K% /f Reg add %K% /f /v Flags /t REG_DWORD /d 20 Reg add %K% /f /v Title /d "Post setup" Reg add %K%\10 /f /ve /d "Console" Reg add %K%\10 /f /v 1 /d "reg import %SystemDrive%\Install\console.reg" Reg add %K%\20 /f /ve /d "Remove unnecessary fonts" Reg add %K%\20 /f /v 1 /d "%SystemDrive%\Install\rm_extra_fonts.cmd" Reg add %K%\30 /f /ve /d "User Pictures" Reg add %K%\30 /f /v 1 /d "%SystemDrive%\Install\userpics.cmd" Reg add %K%\40 /f /ve /d "Views & Shortcuts" Reg add %K%\40 /f /v 1 /d "%SystemDrive%\Install\rm_views.cmd" Reg add %K%\40 /f /v 2 /d "%SystemDrive%\Install\shortcuts.cmd" Reg add %K%\50 /f /ve /d "IE9 Flash ActiveX" Reg add %K%\50 /f /v 1 /d "%SystemDrive%\Install\flPlayer_ax.exe" Reg add %K%\60 /f /ve /d "Silent Visual C++ Redistributable" Reg add %K%\60 /f /v 1 /d "%SystemDrive%\Install\vcRedist.exe auto" Reg add %K%\70 /f /ve /d "Reboot" Reg add %K%\70 /f /v 1 /d "shutdown.exe /r /t 100" rundll32.exe iernonce.dll,RunOnceExProcess EndLocal Exit /b 0
In my Autounattend.xml I edited the CommandLines to read:
<FirstLogonCommands>
<SynchronousCommand wcm:action="add">
<CommandLine>cmd /C start /wait %systemdrive%\Windows\setup\scripts\activate.cmd</CommandLine>
<Order>1</Order>
</SynchronousCommand>
<SynchronousCommand wcm:action="add">
<CommandLine>cmd /C start /wait %systemdrive%\Install\RunOnceEx.cmd</CommandLine>
<Order>2</Order>
</SynchronousCommand>
</FirstLogonCommands>
I don't see a difference stuffing single commands into <SynchronousCommand> sections or calling one cmd containing the necessary commands.
Well, what might that be...?
#9
Posted 09 November 2012 - 03:34 PM
Reg add %K%\20 /f /v 1 /d "CMD /C Start /Wait %SystemDrive%\Install\rm_extra_fonts.cmd"
#10
Posted 09 November 2012 - 05:44 PM
#11
Posted 11 November 2012 - 02:14 PM
In short: It didn't work with cmd /c start /wait %SystemDrive%\Install\rm_extra_fonts.cmd.
After removing the start /wait part, finally the cmd instance auto-closed. (Combined with hidec.exe /w an output may be completely hidden.)
Checking the test installation I noticed that several changes of the cmd scripts weren't carried out properly.
I had to execute rm_views.cmd and shortcuts.cmd again manually, that's annoying.
I assume that it has to do with the moment when the Windows graphics (theme) is loaded, all my cmd scripts run before.
In Windows XP I sorted shortcuts with a VBS script at one of the last RunOnceEx entries (and I remember that at first it didn't work as expected).
Registry files are also not fully applied (e.g. via reg import HKCU.reg) yet.
Addendum:
In some thread I saw an example of a cmd script (copying stuff to a virgin installation) with several Timeout /t 1 in it.
Do you use this command and if so, under which circumstances?
This post has been edited by Mikka: 12 November 2012 - 05:21 AM
#12
Posted 12 November 2012 - 07:29 AM
/k also don't seem to work for me
Maybe some examples
Firefox which I have been doing for quite some time and I am completely setup afterwards. I may still have to enter a pass on some sites but some work
I do use an Autoit script with this available here http://www.msfn.org/...post__p__888493
Notice Example Firefox 3.x.x: on my post there. yes same way since version 3.x
EDIT: Still works even with Windows 8
SET KEY=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx REG ADD %KEY% /V TITLE /D "RunOnceEx - Testing Applications" /f REG ADD %KEY% /v Flags /t REG_DWORD /d "20" /f REG ADD %KEY%\1001 /VE /D "Mozilla Firefox 16.xx" /f REG ADD %KEY%\1001 /V 101 /D "CMD /C Start /Wait D:\APPS\Mozilla.Firefox_X.XX\Firefox_autoit.exe" /f REG ADD %KEY%\1001 /V 102 /D "CMD /C Start /Wait Timeout 3" /f REG ADD %KEY%\1001 /V 103 /D "CMD /C RD \"%USERPROFILE%\AppData\Roaming\Mozilla\Firefox\" /S /Q" /f REG ADD %KEY%\1001 /V 104 /D "CMD /C Start /Wait Timeout 3" /f REG ADD %KEY%\1001 /V 105 /D "cmd /c XCOPY \"D:\APPS\Mozilla.Firefox_X.XX\Firefox\" \"C:\Users\Maxxpsoft\AppData\Roaming\Mozilla\Firefox\" /E /I /H /R /Y" /f REG ADD %KEY%\1001 /V 106 /D "CMD /C DEL \"%SystemDrive%\Users\Public\Desktop\Mozilla Firefox.lnk\"" /f REG ADD %KEY%\1001 /V 107 /D "CMD /C REG DELETE \"HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\MozillaMaintenanceService\" /f" /f" REG ADD %KEY%\1001 /V 108 /D "CMD /C Start /Wait \"%ProgramFiles(x86)%\Mozilla Maintenance Service\uninstall.exe\" /S" /f REG ADD %KEY%\1001 /VE /D "Microsoft Security Essentials x64" /f REG ADD %KEY%\1001 /V 101 /D "CMD /C Start /Wait D:\APPS\MS_SecurityEssentials_x64\mseinstall.exe /s /runwgacheck" /f REG ADD %KEY%\1001 /V 102 /D "CMD /C Start /Wait D:\APPS\MS_SecurityEssentials_x64\SecurityEssentials64.cmd" /f
SecurityEssentials64.cmd uses TASKKILL /F /IM msseces.exe and then it uses setacl to gain permission on registry for Aministrators on keys and set my settings and then return those keys back
Then start "" "C:\Program Files\Microsoft Security Client\msseces.exe"
This post has been edited by maxXPsoft: 12 November 2012 - 07:35 AM
#13
Posted 15 November 2012 - 09:58 AM
I found another one that's working for me. In fact, it's rather simple:
Quote
Reg add %K%\100 /f /v 1 /d "reg.exe add \"HKCU\Software\Microsoft\Windows\CurrentVersion\RunOnce\" /f /v 1 /d %SystemDrive%\Install\shortcuts.cmd"
Reg add %K%\100 /f /v 2 /d "reg.exe add \"HKCU\Software\Microsoft\Windows\CurrentVersion\RunOnce\" /f /v 2 /d %SystemDrive%\Install\cleanup.cmd"
Reg add %K%\110 /f /ve /d "Reboot"
Reg add %K%\110 /f /v 1 /d "shutdown.exe /r /t 30"
A user profile must be accomplished before messing with shortcuts...
Also, tidying up the system partition is reasonably done then, too.



Help
Back to top









