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