Can I set the default printer via a batch file?

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?
 
O

Olof Lagerkvist

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.
 
J

Jerold Schulman

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
 
H

Hank Arnold

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!!
 
O

Olof Lagerkvist

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top