Hello
I have run the script below and its works well but i would like it to return the printer name that is "Laserjet 1320" but instead its returning "client".i want it to return the last part of the printer.and most important thing is that when the next time the user login i don't want it to have two printer one that has just been created and one that has been renamed in the previous login.
Code:
Rem Set the local variables
SetLocal
Rem Wait about 15 seconds to let the terminal server map the printer...
Sleep 15
Rem Reads the default printer from the registry
"%SystemRoot%\Application Compatibility Scripts\acregl.exe" DefPrint.cmd DefaultPrinter "HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows" "Device" ""
If Not Exist DefPrint.cmd (Call :Error 1) && (Goto EoF)
call DefPrint.cmd
del DefPrint.cmd
If Not Defined DefaultPrinter (Call :Error 2) && (Goto EoF)
Rem 2000 :: DefaultPrinter = HP DeskJet 820CSe on oz/TINMAN/Session 1,winspool,TS001
for /f "tokens=1 delims=," %%i in ('"echo %DefaultPrinter%"') do set OldPrinterString=%%i
for /f "tokens=1 delims=\" %%j in ('"echo %DefaultPrinter%"') do set PrinterString=%%j
Rem 2000 :: PrinterString = HP DeskJet 820Cse on oz/%clientname%/session 1
Rem Attempt to rename the printer...
rundll32 printui.dll,PrintUIEntry /Xs /n "%OldPrinterString%" printername "%PrinterString%"
Rem Done!
EndLocal
Goto EoF
:Error
msg %SessionName% /W Your printers were not successfully renamed. Please notify an administrator. (Error Code: %1)
EndLocal
Goto EoF
:EoF
PLease do help me as it is urgent
Thanks in advance
Nazeedah