How to wait for the right time to execute FBA Generic Commands

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I try several actions at the end of FirstBoot (phase > 8500) that I execute
with
a FBAGeneric Command (path: cmd.exe, arg: /c <MyStuff>). My stuff being:
-Rename my LAN connections (through aVB script)
-Change mounted drives (diskpart + command file)

But they all unexplainably failed.
Until I started to use "/k <MyStuff>" as argument to echo some stuff and try
the action manually in case it failed.

Example:

path : cmd.exe
arg : /k echo ChangeMounts && diskpart /s mount.txt

It fails but the cmd -window remain, soI try the same command, and then it
works. And all the other FBAGeneric command that followed also
unexplainably succeeded.

Why??

I think it has something to do with cetain services that were not yet
started when the command was first called.

Can anyone confirm this and if so please offer a way to wait for these
services.

Thijs
 
Why don't you just try pushing the phase out to something like 11000. This
is where I usually do things just to make sure that the system items have
had time to stablize.
 
Just running my commands at at later phase, 11000 as suggested, doesn't solve
my problem.

1. Found out that diskpart.exe, for changing the drive mounts, relies on the
dmserver and dmadmin services.
The dmserver is normally allready running and dmadmin is started by
diskpart. But for some reason just running
diskpart doesn't get them up and running, so I created the follwing batch
file to just keep on trying.

================================

@echo off

set COUNT=1
:START
echo.
echo Running DiskPart . . . (try=%COUNT%)
diskpart /s %1
echo.
if %errorlevel%==5 echo A command syntax error occurred. The script failed
because an object was improperly selected or was invalid for use with that
command.
if %errorlevel%==4 echo One of the services DiskPart uses returned a failure
if %errorlevel%==3 echo DiskPart was unable to open the specified script or
output file.
if %errorlevel%==2 echo The parameters specified for a DiskPart command were
incorrect.
if %errorlevel%==1 echo A fatal exception occurred. There may be a serious
problem.
if %errorlevel%==0 echo No errors occurred. The entire script ran without
failure.
if %errorlevel%==0 goto END
if not %errorlevel%==4 goto ERROR
sc query dmserver
sc query dmadmin
set /a COUNT=%COUNT%+1
goto START

:ERROR
echo.
pause

:END

================================

Inserted the "sc query" command just to take up somne time and to show that
they're not running yet.


2. The problem here is that the network adapters are properly named (Local
Area Connection) until
the first start of the explorer.exe. Before this they just have some
GUID-like ID as name.
So trying this before the first start of the explorer doesn't work.

========================================
Const NETWORK_CONNECTIONS = &H31&

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(NETWORK_CONNECTIONS)

Set colItems = objFolder.Items
For Each objItem in colItems
If objItem.Name = "Local Area Connection" Then
objItem.Name = "Machine"
End If
If objItem.Name = "Local Area Connection 2" Then
objItem.Name = "Network"
End If
Next
=======================================

First I dumped the VBS-script for renaming my LAN connection when I found
out that netsh can do the same. Then
I in found a call to rename the connections, used when there is no explorer
shell at all. This all resulted
in the batch file below

=============================================

@echo off

set COUNT=1
:NAME
echo.
echo Naming network adapters . . . (try=%COUNT%)
rundll32.exe netshell.dll HrRenameConnection
netsh.exe interface show interface name="Local Area Connection">NULL
set /a COUNT=%COUNT%+1
if %errorlevel%==1 goto NAME
echo.
echo Successfully named all network adapters

set COUNT=1
:RENAME_1
echo.
echo Renaming network adapter "Local Area Network" to "Machine" . . .
(try=%COUNT%)
netsh.exe interface set interface name="Local Area Connection"
newname="Machine"
set /a COUNT=%COUNT%+1
if %errorlevel%==1 goto RENAME_1
echo Successfully renamed network adapter

set COUNT=1
:RENAME_2
echo.
echo Renaming network adapter "Local Area Network 2" to "Network" . . .
(try=%COUNT%)
netsh.exe interface set interface name="Local Area Connection 2"
newname="Network"
set /a COUNT=%COUNT%+1
if %errorlevel%==1 goto RENAME_2
echo Successfully renamed network adapter

set COUNT=1
:CONFIG
echo.
echo Configuring adapter "Machine" . . . (try=%COUNT%)
netsh.exe interface ip set address name="Machine" source=static
addr=194.120.123.71 mask=255.255.255.0
set /a COUNT=%COUNT%+1
if %errorlevel%==1 goto CONFIG
echo Successfully configured network adapter

set COUNT=1
:FIREWALL
echo.
echo Disabling Windows Firewall . . . (try=%COUNT%)
netsh.exe firewall set opmode mode=DISABLE
set /a COUNT=%COUNT%+1
if %errorlevel%==1 goto FIREWALL
echo Successfully disabled Windows Firewall
:END
=========================================


Thijs
 
This is nice work!
Diskpart has been failing to activate my partitions from the install
script on me **Sometimes***, and I haven't known why.
I can use this batch file to help figure it out.

Steves
stevesATeyeDASHimagingDOTcom
 
Back
Top