Help - Search - Members - Calendar
Full Version: Access %WPIPATH% from within batch files
MSFN Forums > Member Contributed Projects > Windows Post-Install Wizard (WPI)

   
Google Internet Forums Unattended CD/DVD Guide
/usr/local/dick
Hi guys

I'm have succeeded in automatically installing printers with WPI, by using vbscript.
I also want to configure default options (Duplex feature) on some printers.
And finally, I want newly created user account to already have a preference to print duplex on those.
To do this last step, I needed to run multiple REG IMPORT commands, so I created a batchfile:

CODE
REG IMPORT "%WPIPATH%\Install\Printer Scripts\PrintersConfig.reg"
REG IMPORT "%WPIPATH%\Install\Printer Scripts\UserPrefs_HKCU.reg"
REG LOAD HKEY_USERS\Default_User "C:\Documents and Settings\Default User\ntuser.dat"
REG IMPORT "%WPIPATH%\Install\Printer Scripts\UserPrefs_Default_User.reg"
REG UNLOAD HKEY_USERS\Default_User


This batchfile itself is run from WPI as:

CODE
"%wpipath%\Install\Printer scripts\CustomConfig.bat"


However, the %wpipath% variable is not available in my batch file...

I solved it by calling it with wpipath as first argument:


CODE
"%wpipath%\Install\Printer scripts\CustomConfig.bat" %wpipath%


and then using %1 in my batch file:


CODE
REG IMPORT "%1\Install\Printer Scripts\PrintersConfig.reg"
REG IMPORT "%1\Install\Printer Scripts\UserPrefs_HKCU.reg"
REG LOAD HKEY_USERS\Default_User "C:\Documents and Settings\Default User\ntuser.dat"
REG IMPORT "%1\Install\Printer Scripts\UserPrefs_Default_User.reg"
REG UNLOAD HKEY_USERS\Default_User


This works fine but I wonder if it is the Right Way...

bszom
I think the way you've done it is perfectly fine.

Another alternative, assuming you're doing an unattended Windows install, would be to put your .reg files somewhere in the <Your CD>\$OEM$\$1\ directory structure. So for example, you could just copy your folder "Printer Scripts" into the $1 directory. This will cause "Printer Scripts" to be copied to the system drive (usually C drive) when Windows is installed, allowing you to reference your .reg files as follows: "%SYSTEMDRIVE%\Printer Scripts\<whatever>.reg".

Please note that you must set "OemPreinstall=Yes" in your WINNT.SIF for the contents of <Your CD>\$OEM$\$1\ to be copied to the system drive.

More information:
WINNT.SIF Reference
$OEM$ Distribution Folders
AlBundy33
On WPI-Start I create SetWPIEnv.cmd on %SystemDrive% which sets some variables:
createSetWPIEnv.cmd
CODE
@ECHO OFF
SET CMD=%SYSTEMDRIVE%\SetWPIEnv.cmd

SET HIDEWINDOW=no
SET DISABLE_CLEANUP=no
SET DISABLE_INSTALL=yes

:PARSE
    IF /I "%~1"=="-h"  SET HIDEWINDOW=yes
    IF /I "%~1"=="-c"  SET DISABLE_CLEANUP=no
    IF /I "%~1"=="-dc" SET DISABLE_CLEANUP=yes
    IF /I "%~1"=="-i"  SET DISABLE_INSTALL=no
    IF /I "%~1"=="-di" SET DISABLE_INSTALL=yes
    SHIFT
    IF NOT "%~1"=="" GOTO :PARSE

CALL :OUTPUT>"%CMD%"

GOTO :EOF

:OUTPUT
    SET TMP=%~dp0
    SET TMP=%TMP:~0,-7%
    ECHO @ECHO OFF
    ECHO.
    ECHO.SET HIDEWINDOW=%HIDEWINDOW%
    ECHO.SET DISABLE_CLEANUP=%DISABLE_CLEANUP%
    ECHO.SET DISABLE_INSTALL=%DISABLE_INSTALL%
    ECHO.
    ECHO SET ROOT=%TMP%
    ECHO SET WPIPATH=%TMP%\WPI
    ECHO SET CDROM=%~d0
    ECHO SET PATH=%%PATH%%;%TMP%\Tools
    ECHO.
    ECHO IF /I "%%HIDEWINDOW%%"=="yes" IF EXIST "%%ROOT%%\Tools\cmdow.exe" "%%ROOT%%\Tools\cmdow.exe" @ /HID
    ECHO.
    GOTO :EOF

which will create a batch like this
SetWPIEnv.cmd
CODE
@ECHO OFF

SET HIDEWINDOW=no
SET DISABLE_CLEANUP=no
SET DISABLE_INSTALL=yes

SET ROOT=D:\System
SET WPIPATH=D:\System\WPI
SET CDROM=D:
SET PATH=%PATH%;D:\System\Tools

IF /I "%HIDEWINDOW%"=="yes" IF EXIST "%ROOT%\Tools\cmdow.exe" "%ROOT%\Tools\cmdow.exe" @ /HID

Each Batch-File checks if that file exists an runs it - so I have access to all Tools, Paths and so on.
Google Internet Forums Unattended CD/DVD Guide
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.