Jump to content

FirstLogonCommands failing


Recommended Posts

OK so after MUCH faffing around with vlite adn rt7lite and unattend.xml generators I have an answerfile which DOESN'T ask for language etc during winpe setup (trying to get it to use en-GB and not ask during winpe setup was crazy) and DOES leave the pc in en-GB (UK) mode.

So now I'm on to the post-setup part - I've tried various runsynchronous and such but what I really want is a batch file from the setup source drive to run and I put my instructions in there. I don't want to ues setupcomplete.cmd method because despite woring perfectly including the installs which are now failing - it runs while the screen says "testing video performance" or whatever it is, and I don't want it running then, I'd prefer it while the setup shows "completing setup" or during logon - hence using firstlogoncommands.

So my autounattend.xml now has a firstlogoncommand pointing to a FirstRun.cmd in windows\setup\scripts which is copied there from $OEM$ on the source media. This works and fires the firstrun.cmd which checks the drivelist for the installdrive and runs [installdrive]\FirstRun\FirstRun.bat - all good so far.

I've checked via writing to c:\Setuplog.txt during the FirstRun.bat and the script IS running all the way down. But it's not doing the important tasks in the script even though it runs right through! The script DOES manage to delete the xml from windows\panther and DOES manage to delete the script files from windows\setup\scripts but it DOESN'T run the dotnet4 install /quiet /norestart which it should and DOESN'T succeed in running a regfile which has tweaks in it.Is there a reason firstlogon can't install dotnet4 or merge a regfile? I repeat - the script definately runs right to the end. And I'm SURE it was working last night at some point during tests.

Is this a problem with credentials that firstlogoncommands runs under? Setup is set to autologon admin once so it should run udner this if anything. And can anyone confirm what is onscreen when firstlogoncommands is running? My batchfile never appears which is used to with runonceex on XP deployments.

Below is my Firstrun.bat


@echo off
echo %date% %time% Firstrun.bat >> c:\Setuplog.txt

REM Called from %windir%\Setup\Scripts\FirstRun.cmd
REM Which is copied from [InstallDrive]\sources\$OEM$\$$\Setup\Scripts\FirstRun.cmd

echo Installing .NET 4 ...
echo.

echo %date% %time% Before dotnet4 >> c:\Setuplog.txt

dotNetFx40_Full_x86_x64.exe /Quiet /NoRestart

echo Running reg edits ...
echo.

echo %date% %time% Before REG >> c:\Setuplog.txt

regedit /s WIN7IE89WMP11.REG

echo Removing sysprep files ...
echo.

del /Q /F %WINDIR%\system32\sysprep\unattend.xml
del /Q /F %WINDIR%\panther\unattend.xml
del /Q /F %WINDIR%\Setup\Scripts\SetupComplete.bak.cmd
del /Q /F %WINDIR%\Setup\Scripts\SetupComplete.cmd
del /Q /F %WINDIR%\Setup\Scripts\FirstRun.cmd

echo %date% %time% Before reboot >> c:\Setuplog.txt

echo Now rebooting ...

ping 127.0.0.1 -n 10 > nul

shutdown -r -t 0

Below is my xml


<?xml version="1.0" encoding="utf-8"?>
<unattend xmlns="urn:schemas-microsoft-com:unattend">
<settings pass="windowsPE">
<component name="Microsoft-Windows-International-Core-WinPE" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="NonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SetupUILanguage>
<UILanguage>en-US</UILanguage>
</SetupUILanguage>
<InputLocale>0809:00000809</InputLocale>
<UserLocale>en-GB</UserLocale>
<UILanguage>en-US</UILanguage>
<SystemLocale>en-GB</SystemLocale>
</component>
<component name="Microsoft-Windows-Setup" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="NonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ImageInstall>
<OSImage>
<InstallFrom>
<MetaData wcm:action="add">
<Key>/IMAGE/NAME</Key>
<Value>Windows 7 PROFESSIONAL</Value>
</MetaData>
</InstallFrom>
<InstallToAvailablePartition>false</InstallToAvailablePartition>
<WillShowUI>OnError</WillShowUI>
</OSImage>
</ImageInstall>
<UserData>
<ProductKey>
<Key></Key>
<WillShowUI>OnError</WillShowUI>
</ProductKey>
<Organization>Org</Organization>
<FullName>Name</FullName>
<AcceptEula>true</AcceptEula>
</UserData>
</component>
</settings>
<settings pass="oobeSystem">
<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="NonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<OOBE>
<HideEULAPage>true</HideEULAPage>
<NetworkLocation>Work</NetworkLocation>
<ProtectYourPC>3</ProtectYourPC>
<SkipMachineOOBE>true</SkipMachineOOBE>
<SkipUserOOBE>true</SkipUserOOBE>
</OOBE>
<UserAccounts>
<AdministratorPassword>
<Value>password</Value>
</AdministratorPassword>
</UserAccounts>
<AutoLogon>
<Password>
<Value>password</Value>
</Password>
<Enabled>true</Enabled>
<LogonCount>1</LogonCount>
<Username>Administrator</Username>
</AutoLogon>
<FirstLogonCommands>
<SynchronousCommand wcm:action="add">
<Order>1</Order>
<Description>Run FirstRun.cmd</Description>
<CommandLine>%WINDIR%\Setup\Scripts\FirstRun.cmd</CommandLine>
</SynchronousCommand>
</FirstLogonCommands>
</component>
</settings>
<settings pass="specialize">
<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="NonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ComputerName>Win7SP1</ComputerName>
</component>
<component name="Microsoft-Windows-Security-Licensing-SLC-UX" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="NonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SkipAutoActivation>true</SkipAutoActivation>
</component>
</settings>
<cpi:offlineImage cpi:source="" xmlns:cpi="urn:schemas-microsoft-com:cpi" />
</unattend>

Link to comment
Share on other sites


Nope - as it says at the top of FirstRun.bat - it is being called by FirstRun.cmd which is in %windir%\setup\scripts and which is called from firstlogoncommands. FirstRun.cmd looks like this


@echo off
echo %date% %time% Firstrun.cmd >> c:\Setuplog.txt

cls
color 2a

for %%i in (b: c: d: e: f: g: h: i: j: k: l: m: n: o: p: q: r: s: t: u: v: w: x: y: z:) do if exist %%i\FirstRun\FirstRun.bat %%i\FirstRun\FirstRun.bat

More importantly like I said the FirstRun.bat is running fine (and outputs to setuplog.txt fine) it's just failing to install and merge the regfile

Edited by leozack
Link to comment
Share on other sites

You can try to add the reg file inside: $OEM$\$\Setup\Scripts

And use inside your batch file:

REGEDIT /S "%systemroot%\Setup\scripts\WIN7IE89WMP11.REG"

Useful sharing about: dotNetFx40_Full_x86_x64.exe silent install:

http://www.wincert.net/forum/index.php?/topic/9154-slim-net-framework-40-11-07-2011/

*Edit: Inside your Autounattend.xml file you can also change the value, to:


<component name="Microsoft-Windows-Security-SPP-UX" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SkipAutoActivation>true</SkipAutoActivation>

Edited by myselfidem
Link to comment
Share on other sites

I want to keep the stuff I'm running outside of the scripts folder and on the installdevice for easier editing etc. Why can't it merge a regfile in the same folder on the device rather than needing to be on the hd in the scripts dir?

That dotnet4 package looks interesting but why isn't the normal one installing when it does if I call it from setupcomplete.cmd instead?

What's the difference on that final component name? I'm sure I already changed that ones possibly because WAIK complained it was outdated or something? Hmm

Link to comment
Share on other sites

I love you. Whilst stating the obvious I hadn't considered that a batchfile would have problems referring to files in its own path. Seems rubbish that setupcomplete.cmd can call files just by name but because I'm using firstlogoncommands I haev to specify the full path in batch file even to a file in the same location! But it worked anyway, and the setup log reveals it took 15m installing dotnet4! I don't remember it taking so long when doing it behind "checking video performance" in setupcomplete.cmd but I guess it must have. At least I see the command prompt window now so I can see how my batchfile is progressing same as I could in XP. Of course technically this means someone could close it but that shouldn't be an issue. Here's my new FirstRun.bat which uses the same drive scanning technique to find it's own path as FirstRun.cmd used to find FirstRun.bat

I guess now I should consider filling the script up with windows/ie/dotnet updates to avoid them coming down with WSUS etc. Hmmm :/

I'm also wondering why despite this working it logged in and unlike every other time when the batch hasn't worked, I haev no IE icon anywhere on startmenu/desktop/taskbar and the theme is in classic or otherwise corrupted? Hmmm I didn't think my regfile would break it - it seems to have worked

PS does anyone know how to globally disable the "use checkboxes for selection" option and "user sharing wizard" option in win7? I found some regkeys but changing them alone didn't put the setting back :/

FirstRun.bat


@echo off
echo %date% %time% Firstrun.bat >> c:\Setuplog.txt

REM Called from %windir%\Setup\Scripts\FirstRun.cmd
REM Which is copied from [InstallDrive]\sources\$OEM$\$$\Setup\Scripts\FirstRun.cmd

for %%i in (b: c: d: e: f: g: h: i: j: k: l: m: n: o: p: q: r: s: t: u: v: w: x: y: z:) do if exist %%i\FirstRun\FirstRun.bat set InstalSource=%%i\FirstRun

echo Installing .NET 4 ...
echo.

echo %date% %time% Before dotnet4 >> c:\Setuplog.txt

%InstalSource%\dotNetFx40_Full_x86_x64.exe /Quiet /NoRestart

echo Running reg edits ...
echo.

echo %date% %time% Before REG >> c:\Setuplog.txt

regedit /s %InstalSource%\WIN7IE89WMP11.REG

echo Removing sysprep files ...
echo.

del /Q /F %WINDIR%\system32\sysprep\unattend.xml
del /Q /F %WINDIR%\panther\unattend.xml
del /Q /F %WINDIR%\Setup\Scripts\SetupComplete.bak.cmd
del /Q /F %WINDIR%\Setup\Scripts\SetupComplete.cmd
del /Q /F %WINDIR%\Setup\Scripts\FirstRun.cmd

echo %date% %time% Before reboot >> c:\Setuplog.txt

echo Now rebooting ...

ping 127.0.0.1 -n 10 > nul

set InstallSource=

shutdown -r -t 0

RegFile


Windows Registry Editor Version 5.00

[-HKEY_LOCAL_MACHINE\Software\RT 7 Lite]

; -------------- Remove Bing & set Google.co.uk to default searchscope

[-HKEY_CURRENT_USER\SOFTWARE\Microsoft\Internet Explorer\SearchScopes\{0633EE93-D776-472f-A0FF-E1416B8B2E3A}]
[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\SearchScopes\{758B870D-DF78-4A6A-9955-DEDDCACF94DC}]
"DisplayName"="Google"
"URL"="http://www.google.co.uk/search?q={searchTerms}&rls=com.microsoft:{language}&ie={inputEncoding}&oe={outputEncoding}&startIndex={startIndex?}&startPage={startPage}"
"ShowSearchSuggestions"=dword:00000001
"SuggestionsURL"="http://suggestqueries.google.co.uk/complete/search?output=firefox&client=IE8&qu={searchTerms}"
"OSDFileURL"="http://download.microsoft.co.uk/download/A/3/C/A3C89D63-E2F0-460D-9F5F-23B51EA52B5E/Google.xml"
"FaviconURL"="http://www.google.co.uk/favicon.ico"
"FaviconPath"="http://www.google.co.uk/favicon.ico"
"SuggestionsURLFallback"="http://clients5.google.co.uk/complete/search?hl={language}&q={searchTerms}&client=ie8&inputencoding={inputEncoding}&outputencoding={outputEncoding}"
"FaviconURLFallback"="http://www.google.co.uk/favicon.ico"
[-HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\SearchScopes\{0633EE93-D776-472f-A0FF-E1416B8B2E3A}]
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\SearchScopes\{758B870D-DF78-4A6A-9955-DEDDCACF94DC}]
"DisplayName"="Google"
"URL"="http://www.google.co.uk/search?q={searchTerms}&rls=com.microsoft:{language}&ie={inputEncoding}&oe={outputEncoding}&startIndex={startIndex?}&startPage={startPage}"
"ShowSearchSuggestions"=dword:00000001
"SuggestionsURL"="http://suggestqueries.google.co.uk/complete/search?output=firefox&client=IE8&qu={searchTerms}"
"OSDFileURL"="http://download.microsoft.co.uk/download/A/3/C/A3C89D63-E2F0-460D-9F5F-23B51EA52B5E/Google.xml"
"FaviconURL"="http://www.google.co.uk/favicon.ico"
"FaviconPath"="http://www.google.co.uk/favicon.ico"

; -------------- Erase cache when closing Internet Explorer

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Cache]
"Persistent"=dword:00000000
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Cache]
"Persistent"=dword:00000000

; -------------- Disable the Information Bar popup

[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\InformationBar]
"FirstTime"=dword:00000000

; -------------- Disable information bar pre-download nag

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3]
"2200"=dword:00000000

; -------------- disable the prompt when you click on "Diagnose Network Problems" in tools menu

[HKEY_CURRENT_USER\Software\Microsoft\Network Diagnostic]
"SqmEnabled"=dword:00000000

; -------------- Use small icons on commandbar

[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\CommandBar]
"SmallIcons"=dword:00000000

; -------------- Disable firstrun

[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\InformationBar]
"FirstTime"=dword:00000000

; -------------- Lock the toolbar

[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Toolbar]
"Locked"=dword:00000000

; -------------- Remove Tabs welcome

[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\TabbedBrowsing]
"ShowTabsWelcome"=dword:00000000

; -------------- Disable Internet Explorer Cookie "Privacy Icon" prompt

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings]
"PrivDiscUiShown"=dword:00000001

; -------------- Disable Internet Explorer Privacy warning "Send information to the Internet" prompt

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3]
"1601"=dword:00000000

; -------------- Phishing Filter default settings

[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\PhishingFilter]
"EnabledV8"=dword:0000000
"EnabledV9"=dword:0000000

; -------------- IE8/9

[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\LinksBar]
"Enabled"=dword:00000000

[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main]
"IE8RunOnceLastShown"=dword:00000001
"IE8RunOnceLastShown_TIMESTAMP"=hex:b9,77,06,7b,59,c7,c9,01
"IE8RunOncePerInstallCompleted"=dword:00000001
"IE8RunOnceCompletionTime"=hex:40,55,43,8b,59,c7,c9,01
"IE8TourShown"=dword:00000001
"IE8TourShownTime"=hex:b1,41,4f,8b,59,c7,c9,01
"IE9RunOncePerInstallCompleted"=dword:00000001
"IE9RunOnceCompletionTime"=hex:40,55,43,8b,59,c7,c9,01
"IE9TourShown"=dword:00000001
"IE9TourShownTime"=hex:b1,41,4f,8b,59,c7,c9,01
"DisableFirstRunCustomize"=dword:00000001

; -------------- Various

[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main]
"NoUpdateCheck"=dword:00000001
"Disable Script Debugger"="yes"
"Anchor Underline"="yes"
"Cache_Update_Frequency"="Once_Per_Session"
"Save_Session_History_On_Exit"="no"
"Show_StatusBar"="yes"
"Show_ToolBar"="yes"
"AlwaysShowMenus"=dword:00000001
"Show_URLinStatusBar"="yes"
"Show_URLToolBar"="yes"
"Use_DlgBox_Colors"="yes"
"FullScreen"="no"
"NotifyDownloadComplete"="no"
"FormSuggest PW Ask"="no"
"DisableScriptDebuggerIE"="yes"

Edited by leozack
Link to comment
Share on other sites

Well that confirms it - by just rem'ing out the dotnet install line (%InstalSource%\dotNetFx40_Full_x86_x64.exe /Quiet /NoRestart) the setup finishes into windows and I DON'T have the 'corrupted' profile in classic theme etc. So something about just running this breaks the default profile? :( It worked fine when run as setupcomplete.cmd! Grrr why does that have to be covered by a silly testing video screen .....

Link to comment
Share on other sites

yep during setupcomplete only thing I see is dxsetup come up

;41 Use Sharing Wizard - Disabled

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced]

"SharingWizardOn"=dword:00000000

I apply in cleanup.cmd before reboot

Link to comment
Share on other sites

Not sure you mean with "yep during setupcomplete only thing I see is dxsetup come up". If running setupcomplete.cmd makes everything work properly I wuld use it if it wasn't hidden behind the video test messaeg! So I'm forced to use firstlogoncommands but it seems just installing dotnet4 from there breaks the efault profile somehow? :/

Also if you toggle the options in explorer folder options you find under

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced]

there are various keys

SharingWizardOn I can set to 0

AutoCheckSelect I can set to 0

NavPaneExpandToCurrentFolder I can set to 1

But if I then look in explorer they haven't done anything. Do they not get applied until next logon? Because curently although the options changes those reg entries, changing the regentries doesn't change the explorer option!

Link to comment
Share on other sites

some need reboot to apply and that is why I run them in cleanup which reboots my PC

If you go apply them in Explorer they instantly take effect. Can't force that with a reg file that I know of.

I was recently missing the 'Always show icons, never thumbnails' which doesn't allow thumbnails to show in pic folders

I done this and had to reboot but it is a policy

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer]

"DisableThumbnails"=dword:00000000

Link to comment
Share on other sites

So my win7 section at the top of my regfile looks like this now


[-HKEY_LOCAL_MACHINE\Software\RT 7 Lite]
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced]
"SharingWizardOn"=dword:00000000
"AutoCheckSelect"=dword:00000000
"NavPaneExpandToCurrentFolder"=dword:00000001

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Folder\AutoCheckSelect]
"DefaultValue"=dword:00000000
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Folder\SharingWizardOn]
"DefaultValue"=dword:00000000

and tha works fine.

But definately now - if I run the dotnet4 installer or the slim/updates-included dotnet4 installer - when it logs on I get a corrupted grey profile ... wtf is wrong with installing dotnet4 at firstruncommands time to cause this? It doesn't happen if I install it at setupcomplete.cmd time!

Link to comment
Share on other sites

But definately now - if I run the dotnet4 installer or the slim/updates-included dotnet4 installer - when it logs on I get a corrupted grey profile ... wtf is wrong with installing dotnet4 at firstruncommands time to cause this? It doesn't happen if I install it at setupcomplete.cmd time!

then run it in setupcomplete

I don't know because I have no application requiring .Net 4 so I just don't install it

perhaps log the operation to see what going on?

post-9484-0-96625700-1321123452_thumb.pn

Link to comment
Share on other sites

Like I already said I don't want to use setupcomplete.cmd time since that happens behind a stupid "testing video performance" screen.

How can I log it and see what's going on?

Though as far as I can imagine I could have everything logged but it won't help if I don't know what to look for - is it some reg entry in the profile being corrupted? I see no way to even know!

Link to comment
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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...