Mikka Posted November 5, 2012 Posted November 5, 2012 Hi pros,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.
Tripredacus Posted November 6, 2012 Posted November 6, 2012 Look at this thread, starting with this post: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.
maxXPsoft Posted November 6, 2012 Posted November 6, 2012 (edited) The user does exist at FirstLogonCommands. I run a themepack install, copy Favorites, set my Powerplan and apply my tweaks REGEDIT /S %systemdrive%\Install\Se7en_UATweaks.regI do most of that with DVD\sources\$OEM$ and RunOnceEx is still alive and well even on Win 8 Edited November 6, 2012 by maxXPsoft
Mikka Posted November 6, 2012 Author Posted November 6, 2012 (edited) Thank you.@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.xmlW7DVD\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 offstart /wait C:\Windows\setup\scripts\activate.cmdstart /wait C:\Install\RunOnceEx.cmdexit/b 0And a (basic) RunOnceEx.cmd looks like this:@echo offSetLocal enableextensionsSet K=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceExReg add %K% /fReg 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,RunOnceExProcessEndLocalExit/b 0However, 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:I'll comment out the 2nd line of setupcomplete.cmd and try again, I'm quite clueless right now. Edited November 6, 2012 by Mikka
maxXPsoft Posted November 6, 2012 Posted November 6, 2012 (edited) uaDVD\sources\$OEM$\$$\SETUP\Scripts\Setupcomplete.cmd Setupcomplete.cmd runs right before Load Desktop and can be used to complete Final Steps. HKLM Reg tweaks can be ran here but not HKCU which are user specific. I run updates and stuff which can't be injected like directx_Jun2010_redist.exe, VisualC++RedistInstallerV17.exeUse Firstlogoncommands but then you wouldn't need the RunOnceEx unless you want to do something on reboot. I delete Install folder with thatREG ADD HKCU\Software\Microsoft\Windows\CurrentVersion\Runonce /V DelInstall /D "Cmd /C RMDIR %systemdrive%\Install\ /S /Q" /fYou 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> Edited November 6, 2012 by maxXPsoft
Mikka Posted November 6, 2012 Author Posted November 6, 2012 1. RunOnceEx.cmd (or Firstlogon.cmd):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.
maxXPsoft Posted November 6, 2012 Posted November 6, 2012 <RequiresUserInput> remove those lines. Default and best not to addI meant you could probably run all your cmd's one after another instead of the 1 file doing the RunOnceEx
Mikka Posted November 9, 2012 Author Posted November 9, 2012 Thank you, maxXPsoft. Things are improving slowly...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 offSetLocal enableextensionsSet K=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceExReg add %K% /fReg add %K% /f /v Flags /t REG_DWORD /d 20Reg 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,RunOnceExProcessEndLocalExit /b 0In 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...?
maxXPsoft Posted November 9, 2012 Posted November 9, 2012 Add CMD /C Start /Wait in front of each and then add Exit last line of each fileReg add %K%\20 /f /v 1 /d "CMD /C Start /Wait %SystemDrive%\Install\rm_extra_fonts.cmd"
Tripredacus Posted November 9, 2012 Posted November 9, 2012 Alternatively, if you don't want to see the CMDs on the screen, you can use CMD /K instead.
Mikka Posted November 11, 2012 Author Posted November 11, 2012 (edited) It's odd, but obviously RunOnceEx behaves differently in Windows 7 compared to Windows XP.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? Edited November 12, 2012 by Mikka
maxXPsoft Posted November 12, 2012 Posted November 12, 2012 (edited) Try removing SetLocal enableextensions. I don't use that and mine works/k also don't seem to work for meMaybe some examplesFirefox 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 workI do use an Autoit script with this available here Notice Example Firefox 3.x.x: on my post there. yes same way since version 3.xEDIT: Still works even with Windows 8SET KEY=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceExREG ADD %KEY% /V TITLE /D "RunOnceEx - Testing Applications" /fREG ADD %KEY% /v Flags /t REG_DWORD /d "20" /fREG ADD %KEY%\1001 /VE /D "Mozilla Firefox 16.xx" /fREG ADD %KEY%\1001 /V 101 /D "CMD /C Start /Wait D:\APPS\Mozilla.Firefox_X.XX\Firefox_autoit.exe" /fREG ADD %KEY%\1001 /V 102 /D "CMD /C Start /Wait Timeout 3" /fREG ADD %KEY%\1001 /V 103 /D "CMD /C RD \"%USERPROFILE%\AppData\Roaming\Mozilla\Firefox\" /S /Q" /fREG ADD %KEY%\1001 /V 104 /D "CMD /C Start /Wait Timeout 3" /fREG 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" /fREG ADD %KEY%\1001 /V 106 /D "CMD /C DEL \"%SystemDrive%\Users\Public\Desktop\Mozilla Firefox.lnk\"" /fREG 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" /fREG ADD %KEY%\1001 /VE /D "Microsoft Security Essentials x64" /fREG ADD %KEY%\1001 /V 101 /D "CMD /C Start /Wait D:\APPS\MS_SecurityEssentials_x64\mseinstall.exe /s /runwgacheck" /fREG ADD %KEY%\1001 /V 102 /D "CMD /C Start /Wait D:\APPS\MS_SecurityEssentials_x64\SecurityEssentials64.cmd" /fSecurityEssentials64.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 backThen start "" "C:\Program Files\Microsoft Security Client\msseces.exe" Edited November 12, 2012 by maxXPsoft
Mikka Posted November 15, 2012 Author Posted November 15, 2012 Interesting approach, maxXPsoft.I found another one that's working for me. In fact, it's rather simple:Reg add %K%\100 /f /ve /d "Shortcuts"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.
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now