Hello
Thank you for your answers

this the code that i am actually running. I have done some changes but can you please check since i am having an error.


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)
/**here i have have done some changes taht is i add this part so as to rename the printer**/
Dim $NewPrinterName

$NewPrinterName = Split($PrinterName,"\")[Ubound(Split($PrinterName,"\"))]
? $NewPrinterName
/*****changes end***/


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

/****can you please check the line above since the error i receive is from this line**/

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 help me quickly. i really need it.

Let me know if you need additional information
Thank you a Lot
Nazeedah