Can I set the default printer via a batch file?

  • Thread starter Thread starter Hank Arnold
  • Start date Start date
H

Hank Arnold

I have a situation where a small number of users have a problem with their
default printer. We are migrating our users from local profiles on our
Citrix servers to roaming profiles and load balancing on the two Citrix
servers. They get logged on to the least loaded server. It seems that when
they are logged onto one server and then get logged onto the other server,
their default printer get switched back to the printer that is the default
for newly created profiles.

While I'm trying to fix this and figure out why this is happening to only a
small number of people, I would like to figure out a way to have their
default printer set via a batch file in their startup folder. Can this be
done?
 
Hank said:
While I'm trying to fix this and figure out why this is happening to only a
small number of people, I would like to figure out a way to have their
default printer set via a batch file in their startup folder. Can this be
done?

Yes, with a VB script, save it as something with .vbs extension.

CreateObject("WScript.Network").SetDefaultPrinter WScripts.Arguments(0)

This will set the default printer to the printer given as parameter to
the script so you can call it from a batch file.
 
I have a situation where a small number of users have a problem with their
default printer. We are migrating our users from local profiles on our
Citrix servers to roaming profiles and load balancing on the two Citrix
servers. They get logged on to the least loaded server. It seems that when
they are logged onto one server and then get logged onto the other server,
their default printer get switched back to the printer that is the default
for newly created profiles.

While I'm trying to fix this and figure out why this is happening to only a
small number of people, I would like to figure out a way to have their
default printer set via a batch file in their startup folder. Can this be
done?

You can also use the registry.
See tip 672 in the 'Tips & Tricks' at http://www.jsiinc.com

Jerold Schulman
Windows: General MVP
JSI, Inc.
http://www.jsiinc.com
 
Excellent technique! I can log them on, set the printer, export the registry
key to a file, create a batch file that imports the reg file and add it to
the STARTUP folder..... Thanks!!
 
Hank said:
Excellent technique! I can log them on, set the printer, export the registry
key to a file, create a batch file that imports the reg file and add it to
the STARTUP folder..... Thanks!!

You only have to export/import the key
"HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows"
and only the "Device" value there. If you export/import the whole
registry it may take a long time and also change other settings you dont
want to restore everytime a user logs on.
 
Back
Top