Terminal users default printer not staying desfault.

Discussion in 'Scripting' started by saveoncomputers, Aug 2, 2008.

  1. I use terminial servers with network printers. All users can use any printer
    but they set their own default printer. The default printer is lost when they
    log off.
    On 2003 server, I created the logon and logoff script below:

    Logon Script:
    REG IMPORT \\server\DefaultPrinters\%clientname%.reg

    Logoff Script:

    DEL \\server\DefaultPrinters\%clientname%.reg /q

    reg export "HKCU\Software\Microsoft\Windows NT\Currentversion\Windows"
    \\server\DefaultPrinters\%clientname%.reg

    This works great in 2003 but in 2008, the %clientname% variable is not
    created while the logon scripte is run. And, it dissappears before the logoff
    scrip is started.

    IN 2008 I put the logon script in the Startup so it runs and gets the
    %clientnamen% correctly but I don't know how to run a logoff script before
    the %clientname% dissappears...

    Qusetion:
    How do I retain the default printer set by the user from one terminal
    session to the next.
    Does anyone have a way to perform this function in 2008 or another way to
    achieve this goal?

    Thanks,
    Robert
     
    saveoncomputers, Aug 2, 2008
    #1
    1. Advertisements

  2. It was a pain in the @#$ but I found a workaround. This works for 2008
    server.

    Logon Script:
    REM The following lines create a batch file to be run at logoff that will
    create a reg file to be imported at next logon.
    IF NOT %USERDOMAIN%==Domain GOTO :END
    md \\server\defaultprinter\%username%
    REG IMPORT \\server\defaultprinter\%clientNAME%.reg
    echo REG export "HKCU\Software\Microsoft\Windows NT\Currentversion\Windows"
    \\server\defaultprinter\%clientNAME%.reg >
    \\server\defaultprinter\%userNAME%\defaultPrinter.cmd /Y
    :END

    Logoff Script:
    REM Call the batch file that was created during logon.
    IF NOT %USERDOMAIN%==Domain GOTO :END
    call \\server\defaultprinter\%userNAME%\defaultPrinter.cmd
    :END

    Thanks
    Robert
     
    saveoncomputers, Aug 3, 2008
    #2
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.