Sign in to follow this  
Followers 0
Mikka

Best practice for HKCU adds/app installs needed

13 posts in this topic

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.

0

Share this post


Link to post
Share on other sites

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.

0

Share this post


Link to post
Share on other sites

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.reg

I do most of that with DVD\sources\$OEM$

and RunOnceEx is still alive and well even on Win 8

Edited by maxXPsoft
0

Share this post


Link to post
Share on other sites

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.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:

post-89609-0-84379900-1352211441_thumb.p

I'll comment out the 2nd line of setupcomplete.cmd and try again, I'm quite clueless right now. :(

Edited by Mikka
0

Share this post


Link to post
Share on other sites

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.exe

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>

Edited by maxXPsoft
0

Share this post


Link to post
Share on other sites

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. :blink:

Just the setup won't stall this time. RunOnceEx, however, still doesn't work.

0

Share this post


Link to post
Share on other sites

<RequiresUserInput> remove those lines. Default and best not to add

I meant you could probably run all your cmd's one after another instead of the 1 file doing the RunOnceEx

0

Share this post


Link to post
Share on other sites

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 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...?

0

Share this post


Link to post
Share on other sites

Add CMD /C Start /Wait in front of each and then add Exit last line of each file

Reg add %K%\20 /f /v 1 /d "CMD /C Start /Wait %SystemDrive%\Install\rm_extra_fonts.cmd"

0

Share this post


Link to post
Share on other sites

Alternatively, if you don't want to see the CMDs on the screen, you can use CMD /K instead.

0

Share this post


Link to post
Share on other sites

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.

:no:

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 by Mikka
0

Share this post


Link to post
Share on other sites

Try removing SetLocal enableextensions. I don't use that and mine works

/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

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"

Edited by maxXPsoft
0

Share this post


Link to post
Share on other sites

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.

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Recently Browsing   0 members

    No registered users viewing this page.