Jump to content

Access %WPIPATH% from within batch files


Recommended Posts

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:

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:

"%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:

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

and then using %1 in my batch file:

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

Link to comment
Share on other sites


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

Link to comment
Share on other sites

  • 3 weeks later...

On WPI-Start I create SetWPIEnv.cmd on %SystemDrive% which sets some variables:

createSetWPIEnv.cmd

@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

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

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