JSI Tip 0939. Some 16bit apps must print to the device= in WIN.INI.

Jerold Schulman

December 22, 1998

1 Min Read
ITPro Today logo in a gray background | ITPro Today

If you have one of the subject apps, and you have roaming users, you can alter %SystemRoot%WIN.INI by using WININI.BAT.

WININI.BAT uses REG.EXE to extract the users default printer from

HKEY_CURRENT_USERSoftwareMicrosoftWindows NTCurrentVersionWindowsDevice

It then copies WIN.INI to WINI.OLD, creates a WIN.NEW, replacing all occurences of device=, and finally copies WIN.NEW to WIN.INI. A large WIN.INI can take quite some time to process, so strip out any obsolete entries if you can.

To use WININI.BAT, simply call it in a batch job that starts the app or in the logon script:

call winini

WININI.BAT contains:

<p>@echo off<br>for /f "Tokens=*" %%i in ('reg -Quiet -ListValue "HKCUSoftwareMicrosoftWindows NTCurrentVersionWindowsDevice"') do set regprt=%%i<br>REM The above FOR statement is one line.<br>set regprt=%regprt:REG_SZ =%<br>copy %SystemRoot%Win.ini %SystemRoot%win.old<br>if exist %SystemRoot%Win.new del /q %SystemRoot%Win.new<br>FOR /F "Tokens=1* Delims</p><p>" %%i in (%SystemRoot%Win.ini) do call :winini "%%i" "%%j"<br>set b1=<br>set p1=<br>set p2=<br>set regprt=<br>goto end<br>:winini<br>set p1=!%1!<br>set p2=!%2!<br>set p1=%p1:!"=%<br>set p1=%p1:"!=%<br>set p2=%p2:!"=%<br>set p2=%p2:"!=%<br>set b1=%p1:~0,1%<br>if "%b1%"</p>"[" goto bracket
if "%p1%"<p>"" goto end<br>if "%p1%"</p>"device" goto prt
@echo %p1%=%p2% >> %SystemRoot%Win.new
goto end
:bracket
@echo %p1% >> %SystemRoot%Win.new
goto end
:prt
@echo device=%regprt% >> %SystemRoot%Win.new
goto end
:next
del /q %SystemRoot%Win.ini
copy %SystemRoot%Win.new %SystemRoot%Win.ini
:end

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like