Jump to content

Strange problem with FirstLogonCommand from Shared Network Folder


Recommended Posts

Hi,

I have a very strange problem with unattended installation of Windows 7 32-bit. In the past I have used an usb stick to unattended install Windows and run a batch from the stick via FirstLogonCommands. Its working like a charme and tested 100 times.

Now I have decided to switch from usb installation to network/pxe installation. Win7 32-bit-Installation is working fine, autounattended.xml is placed in "sources" folder and works like a charme.

I use the following code to create a shared folder connection and automatically kick a batch file:

                        <FirstLogonCommands>
<SynchronousCommand wcm:action="add">
<Description>Network Share</Description>
<CommandLine>net use z: \\SERVER\INSTALLATION /user:bleh 1000 /persistent:NO</CommandLine>
<Order>1</Order>
<RequiresUserInput>false</RequiresUserInput>
</SynchronousCommand>
<SynchronousCommand wcm:action="add">
<Description>Post Setup Installation</Description>
<CommandLine>cmd /k Z:\INSTALLATION.bat</CommandLine>
<Order>2</Order>
<RequiresUserInput>false</RequiresUserInput>
</SynchronousCommand>
</FirstLogonCommands>

The shared network folder is created. The INSTALLATION.bat starts up. No problem so far. But now comes the confusion. After the batch is starting and pushing the first commands I get the following error message (batch stops):

Das System kann das angegebene Gerät oder die angegebene Datei nicht öffnen.

means The system cannot open the device or file specified. It stops right after the "echo ..done!" line on executing the "goto act_ossel"

Here is a snippet of my batch:

@echo off

REM Treiber installieren
ver | findstr /i "5\.1\." > nul
IF %ERRORLEVEL% EQU 0 goto ver_XP
ver | findstr /i "6\.0\." > nul
IF %ERRORLEVEL% EQU 0 goto ver_Vista
ver | findstr /i "6\.1\." > nul
IF %ERRORLEVEL% EQU 0 goto ver_Win7
goto warn_and_exit

:ver_Win7
if %PROCESSOR_ARCHITECTURE%==x86 (
echo Installing Windows 7 x86 drivers in silent mode now...
start /w %~d0%~p0TREIBER\7_32\DPInst.exe /q
echo.
echo ..done!
) else (
echo Installing Windows 7 x64 drivers in silent mode now...
start /w %~d0%~p0TREIBER\7_64\DPInst.exe /q
echo.
echo ..done!
)
goto act_ossel

:ver_Vista
if %PROCESSOR_ARCHITECTURE%==x86 (
echo Installing Windows Vista x86 drivers in silent mode now...
start /w %~d0%~p0TREIBER\VISTA_32\DPInst.exe /q
echo.
echo ..done!
) else (
echo Installing Windows Vista x64 drivers in silent mode now...
start /w %~d0%~p0TREIBER\VISTA_64\DPInst.exe /q
echo.
echo ..done!
)
goto act_ossel

:ver_XP
if %PROCESSOR_ARCHITECTURE%==x86 (
echo Installing Windows XP x86 drivers in silent mode now...
start /w %~d0%~p0TREIBER\XP_32\DPInst.exe /q
echo.
echo ..done!
) else (
echo Installing Windows XP x64 drivers in silent mode now...
start /w %~d0%~p0TREIBER\XP_64\DPInst.exe /q
echo.
echo ..done!
)
goto act_ossel

:act_ossel
ver | findstr /i "5\.1\." > nul
IF %ERRORLEVEL% EQU 0 goto manucheck
ver | findstr /i "6\.0\." > nul
IF %ERRORLEVEL% EQU 0 goto activate
ver | findstr /i "6\.1\." > nul
IF %ERRORLEVEL% EQU 0 goto activate


:activate
REM Aktivierung durchfuehren
cscript c:\windows\system32\slmgr.vbs /ato
echo.
echo.
echo Windows-Aktivierung durchgefuehrt!
echo.
echo.
goto manucheck

To find out what is wrong I changed the windows 7 part of the batch to:

if %PROCESSOR_ARCHITECTURE%==x86 (
echo Installing Windows 7 x86 drivers in silent mode now...
start /w %~d0%~p0TREIBER\7_32\DPInst.exe /q
echo.
echo ..done!
goto act_ossel
) else (
echo Installing Windows 7 x64 drivers in silent mode now...
start /w %~d0%~p0TREIBER\7_64\DPInst.exe /q
echo.
echo ..done!
goto act_ossel
)

This time the command prompt is pulling two times the error message

Das System kann das angegebene Gerät oder die angegebene Datei nicht öffnen.
. So Im pretty sure its because of the goto act_ossel. Of course I have tried changing it to "goto :act_ossel" and even some simpler name for the variable like active1 instead of act_ossel. I still get this error message.

But thats not all: As I said already the batch is working flawless when installing from usb stick, no error messages at all. After getting the

Das System kann das angegebene Gerät oder die angegebene Datei nicht öffnen.
error message Im sitting at the command prompt as I said. Now if I start the batch manually by just typing "Z:\INSTALLATION.bat" its working like a charme. WTF?

Ok, so in short words:

Unattended installation with a batch file is working like a charme from usb key, but on network installation the batch file stops after some lines because of a goto problem. Starting the batch file manually again and its working.

I have even tried to start another batch file from within the first batch file, making the system I think that im starting it by my fingers and not automatically but I get the same error.

Anybody got a clue what could be wrong in this strange case?

Link to comment
Share on other sites


Is it losing network access temporarily? You could test for e.g. if exist z:\nul then sleep for a few seconds and retry.

I guess if dpinst swaps your network drivers then that would take it down for a bit.

Link to comment
Share on other sites

You should be using a .cmd extension for Windows 7!

Im sitting at the command prompt as I said. Now if I start the batch manually by just typing "Z:\INSTALLATION.bat" its working like a charme. WTF?

This is a good test but FirstLogonCommands doesn't use a command prompt (opened by a user) to process the command. You can try outputting your command to a file using the " > file.log" method to see what exactly isn't working.

Have you tried using CMD /C instead of /K and see if that makes any difference?

Link to comment
Share on other sites

Is it losing network access temporarily? You could test for e.g. if exist z:\nul then sleep for a few seconds and retry.

I guess if dpinst swaps your network drivers then that would take it down for a bit.

Its not losing the network access. I have already tried that with linking the network shared and then do a sleep for x seconds. But that doesnt make any difference.

You should be using a .cmd extension for Windows 7!

I have tried that and it doesnt make any difference.

This is a good test but FirstLogonCommands doesn't use a command prompt (opened by a user) to process the command. You can try outputting your command to a file using the " > file.log" method to see what exactly isn't working.

Can You tell the exactly command? I guess I need to add it to the AutoUnattend.xml?

Have you tried using CMD /C instead of /K and see if that makes any difference?

Yes, its not working either. With cmd /c switch the INSTALL.CMD does not even starts running. :( I have even tried to push the INSTALL.CMD with CALL and START, but this results in not executing it either.

In the meanwhile I have rebuild the INSTALL.CMD (INSTALLATION.bat before) completely.

The beginning looks like this now:

@echo off
ver | findstr /i "5\.1\." > nul
IF %ERRORLEVEL% EQU 0 (
if %PROCESSOR_ARCHITECTURE%==x86 (
echo Installing Windows XP x86 Drivers..
start /w %~d0%~p0TREIBER\XP_32\DPInst.exe /q
)
if %PROCESSOR_ARCHITECTURE%==AMD64 (
echo Installing Windows XP x64 Drivers..
start /w %~d0%~p0TREIBER\XP_64\DPInst.exe /q
)
)
ver | findstr /i "5\.2\." > nul
IF %ERRORLEVEL% EQU 0 (
if %PROCESSOR_ARCHITECTURE%==x86 (
echo Installing Windows 2003 x86 Drivers..
start /w %~d0%~p0TREIBER\2003_32\DPInst.exe /q
)
if %PROCESSOR_ARCHITECTURE%==AMD64 (
echo Installing Windows 2003 x64 Drivers..
start /w %~d0%~p0TREIBER\2003_64\DPInst.exe /q
)
)
ver | findstr /i "6\.0\." > nul
IF %ERRORLEVEL% EQU 0 (
if %PROCESSOR_ARCHITECTURE%==x86 (
echo Installing Windows Vista x86 Drivers..
start /w %~d0%~p0TREIBER\VISTA_32\DPInst.exe /q
)
if %PROCESSOR_ARCHITECTURE%==AMD64 (
echo Installing Windows Vista x64 Drivers..
start /w %~d0%~p0TREIBER\VISTA_64\DPInst.exe /q
)
echo Windows wird aktiviert..
cscript c:\windows\system32\slmgr.vbs /ato >nul
)
ver | findstr /i "6\.1\." > nul
IF %ERRORLEVEL% EQU 0 (
if %PROCESSOR_ARCHITECTURE%==x86 (
echo Installing Windows 7 x86 Drivers
start /w %~d0%~p0TREIBER\7_32\DPInst.exe /q
)
if %PROCESSOR_ARCHITECTURE%==AMD64 (
echo Installing Windows 7 x64 Drivers
start /w %~d0%~p0TREIBER\7_64\DPInst.exe /q
)
echo Windows wird aktiviert..
cscript c:\windows\system32\slmgr.vbs /ato
)
echo Notebook-Hersteller wird ermittelt..
for /f "tokens=1,*" %%i in ('Systeminfo^|find "Systemhersteller"') do set "Systemhersteller=%%j"
If "%Systemhersteller%"=="LENOVO" goto :ibmtools
If "%Systemhersteller%"=="IBM" goto :ibmtools
goto anderetools

Im getting the same error message mentioned in the OP. It occurs right after doing the activation (cscript c:\windows\system32\slmgr.vbs /ato). The interesting thing is, that the "echo Notebook-Hersteller wird ermittelt.." is not even displayed on the screen before the error message, which is the right next command after the activation stuff. This is funny.. a lil bit.

Edited by Tribble
Link to comment
Share on other sites

OMG, its working now!

The magic code is

cmd /C start /wait Z:\INSTALL.cmd

Anybody knows the technical background now why this "special" code is needed for 'network shared folder batch installing' but not for usb installing, because I have no clue. :wacko:

Link to comment
Share on other sites

Ok, command back. Its not working. It was working exactly one time now. with start /wait. After I tried with start only (no wait), it wasnt working. Changing back to start /wait doesnt made it working either (I did some small changes to the batch (primary echo stuff), which Iam trying to revert now.. :rolleyes:

Link to comment
Share on other sites

Is it losing network access temporarily? You could test for e.g. if exist z:\nul then sleep for a few seconds and retry.

I guess if dpinst swaps your network drivers then that would take it down for a bit.

Its not losing the network access. I have already tried that with linking the network shared and then do a sleep for x seconds. But that doesnt make any difference.

Something like this, after running dpinst?

:check
if not exist %~dp0nul ping -n 1 127.0.0.1 & goto :check

Alternatively, you could try copying anything you need from z: to %temp% before running dpinst, because I still reckon that's bouncing your network.

Link to comment
Share on other sites

Thanks for ur reply, uid0.

I started thinking about the network problem either. So I decided to mount the shared network folder with the persistent:YES option. Now during the setup of install.cmd I opened up an explorer window and watched the mounted drive. Whoala, it was disconneced. After this I started thinking how this could happen and had several ideas:

- during the installation of install.cmd LAN-Drivers are updated

- during the installation of install.cmd chipset drivers are updated

Both can or will lead to disconnect the mounted network folder. The only strange thing left is, that I was getting the error after doing the windows activation via install.cmd. I dont think the network drive gets lost, when activating windows. Anyway I have setup a sleep in the install.cmd right after installing the chipset driver and the lan drivers. Now I did another install and whoala, its working. Will give it another ~5 installations with different machines, just to make sure its indeed working.

Alternatively, you could try copying anything you need from z: to %temp% before running dpinst, because I still reckon that's bouncing your network.

This is no option, since there are several gigs to copy.. big waste of time.

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