Ghost Solution Suite

 View Only
  • 1.  Defining the default printer - Windows XP

    Posted Oct 07, 2008 01:25 PM

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



  • 2.  RE: Defining the default printer - Windows XP

    Posted Oct 09, 2008 02:10 PM

    try this visual basic script instead. or you could use pushprinterconnections.exe in group policy.

     

     Video here: http://screencast.com/t/7g1tj2Rba

     

    Option Explicit
    Dim objNetwork, strUNCPrinter, strUNCPrinter1

    'Variables
    strUNCPrinter = "\\chfiles\P0"
    strUNCPrinter1 = "\\chfiles\P5"

    'Section which creates the printer connection
    Set objNetwork = CreateObject("WScript.Network")
    objNetwork.AddWindowsPrinterConnection strUNCPrinter
    objNetwork.AddWindowsPrinterConnection strUNCPrinter1

    ' Here is where we set the default printer to strUNCPrinter
    objNetwork.SetDefaultPrinter strUNCPrinter
    WScript.Quit