• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to change the default printer using a startup script in Windows
#1

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


  Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Add a program to run automatically at startup in Windows 10 Mark 0 740 01-09-2022, 02:21 PM
Last Post: Mark
  Change the location of the Desktop / My Documents and My Pictures in Windows XP Mark 0 5,619 08-06-2012, 11:22 AM
Last Post: Mark
  [LINUX] Little Sitecloner-Script Clones 0 4,563 13-11-2011, 10:51 AM
Last Post: Clones
  How to change your login screen in windows 7 ! windows 7 was my idea 0 5,262 30-09-2011, 12:34 AM
Last Post: windows 7 was my idea
  How To Change Your Login Screen Background On Windows 7 Jamez247 1 7,124 05-07-2010, 08:37 AM
Last Post: hostingclick

Forum Jump: