Last year user Remmie Boston posted regarding problems exectuing a command to set the default printer on his client computers. The original post and solution can be found here. Remmie indicated that the script provided by Xan Todd sucessfully solved the issue.
I'm having a very similar issue in the envrionment I'm managing, but unfortunately haven't had luck getting the script to run properly from a batch file.
The script attempts to make the change to each user account on a machine, but throws an error that reads:
Error: Too many command-line parameters
Path= C:\Documents and Settings\user1\NTUSER.Dat
The opperation completed Successfully
Error: Invalid command-line parameters
The operation completed successfully
C:\>"C:\defaultprinter.bat" user2
Path=C:\Documents and Settings\user2\NTUSER.Dat
The operation completed successfully
Error: Invalid command-line parameters
The operation completed successfully
etc...
The script was used as-is, with the only change being to the "Set Data=" entry.
Any ideas or suggestions would be much appreciated.
Thank you
Copy of script provided by Xan Todd:
@echo off
If NOT "%1"=="" Goto Update
REM ** User Data ***
Set UserRoot=C:\Documents and Settings
Set KeyName=Software\Microsoft\Windows NT\CurrentVersion\Windows
Set Value=Device
Set ValueType=REG_SZ
Set Data=[Your printer data]
REM ** Internal Data***
REG ADD HKU\.Default\%Keyname% /v "%Value%" /t "%ValueType%" /d "%Data%" /f
FOR /F %%p IN ('dir /b "%UserRoot%"') DO %0 %%p
:Update
Set UserPath=%1
Set TempKey=HKU\TEMP
Echo Path = %UserRoot%\%UserPath%\NTUSER.Dat
REG LOAD "%TempKey%" "%UserRoot%\%UserPath%\NTUSER.Dat"
REG ADD "%TempKey%\%KeyName%" /v "%Value%" /t "%ValueType%" /d "%Data%" /f
REG UNLOAD "%TempKey%"