Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5


How to change the default printer using a startup script in Windows
20-01-2012, 04:00 PM
Post: #1
How to change the default printer using a startup script in Windows

How to change the default printer using a startup script in Windows

The problem: You often use remote desktop to connect to your work computer from home or to a terminal session.
You want to print stuff off the remote session to the host / local printer.

The way Remote desktop works when you choose to pull printers through is that it automatically sets the default printer on the remote computer to the same as the local computer. This is normally fine but can be a problem in programs such as Sage.

You COULD manually set a different default printer every time you log on or turn off printer redirection, (not really an option), or just make a quick VBS script.

Open notepad and type the following, you can replace “Microsoft XPS Document Writer” with the exact name of your printer as it appears in the Printers folder.

[code=vb]Set WSHNetwork = CreateObject(“WScript.Network”)
WSHNetwork.SetDefaultPrinter “Microsoft XPS Document Writer”[/code]

File > Save > defaultprinter.vbs (Save it as all file types, not .txt) This script should work straight away if you double click it.

I then added this to the startup folder, (All Programs > Startup), but it wasn't changing the printer as it was running as soon as the user logged in.. to fix this, add a sleep of 20 seconds or so.

[code=vb]WScript.Sleep(20000)[/code]

You could probably do this using Task Scheduler if you really wanted to instead of adding to the startup folder.

So your final code is:
[code=vb]WScript.Sleep(20000)
Set WSHNetwork = CreateObject(“WScript.Network”)
WSHNetwork.SetDefaultPrinter “Microsoft XPS Document Writer”[/code]

This can be a suitable fix for errors like the one below from Sage Reports.

Report design error
Unable to generate the report
Attempted to read or write protected memory failed.
Related process: Sbddesktop.exe



[Image: engrish25.png]
Reply



Forum Jump:


User(s) browsing this thread: 1 Guest(s)