Solved

copy default printer from remote machine

Posted on 2004-10-11
15
256 Views
Last Modified: 2010-04-17
Hello Experts
I am haven trouble finding a way to copy a default printer from one machine to another. When a user log on to the machine the default printer from a remote machine should be added and set to default printer on the users machine.

Can somebody help me?
0
Comment
Question by:aslandk
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 7
15 Comments
 
LVL 58

Expert Comment

by:Julian Hansen
ID: 12285389
This is a bit of a confusing question. Default printers are assigned in the user profile - when users add printers to their profiles they choose which one will be the default.

Unless the user that you want to copy from is logged into the remote machine you are not going to find what you are looking for on that machine. You will find the default printer information in the user registry. But this could get tricky because you first have to figure out if the user is using local or roaming profiles and then figure out where their profile is stored before opening it and browsing to

<profile>\Software\Microsoft\Windows NT\CurrentVersion\Windows\Device

Once you have the printer name the rest is easy: Use the SetDefaultPrinter API call and bingo.

0
 

Author Comment

by:aslandk
ID: 12285594
hehe i know the quaetion is a bit confusion....

The user logges on to citrix and need the deafault printer to be mapped to the profile on the citirx server....it is roaming profile.

Is that more clear?:)
0
 

Author Comment

by:aslandk
ID: 12285654
isent it possible to use the add printer function:

Set WshNetwork = CreateObject("WScript.Network")
WshNetwork.AddWindowsPrinterConnection "\\PrintServer1\Xerox300"
WshNetwork.SetDefaultPrinter "\\PrintServer1\Xerox300"



but make the printername variable to fit the default printer on the local machine?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 58

Expert Comment

by:Julian Hansen
ID: 12285694
Oic - what you want to do is pick up the default printer of the client where the user is connecting to citrix from and then set that default printer on the Citrix / Terminal Server box?

Interesting, one of our products manages profiles and printers in a Citrix environment - but I am not going to discuss that here - ee ethics and all ;)

What I am going to say is if this is what you want to do then we have done exactly this for one of our clients as a freeware solution (sort of a teaser for the main product if you will). If you are interested let me know and I will post a link.

0
 

Author Comment

by:aslandk
ID: 12285735
of course i am interested...waiting for more info form you:):)
0
 
LVL 58

Expert Comment

by:Julian Hansen
ID: 12286846
Ok,

Here is the URL

http://www.managedprofile.com/downloads/mpdefprn.zip

The file contains a working executable that will set the default printer on the TS to the value set on the client. The file also contains the C/C++ source for doing this should you wish to modify it.

HTH
0
 

Author Comment

by:aslandk
ID: 12305691
i have downloade the code...but there is not any "readme.txt" or installation/user guide.

Do you have a guide i can use?
0
 
LVL 58

Expert Comment

by:Julian Hansen
ID: 12305921
Oops - my apologies - very simple utility - just run it in the user Citrix / Terminal server session. It does not require installation or command line parameters - just need to run it.

The source code should be included so you can take a look at what it is doing - if you have problems with the C++ let me know I will see what I can do about posting a VB version.

Julian
0
 

Author Comment

by:aslandk
ID: 12306052
if you have the code in vb i would prefere it...it looks very interesing:)
0
 
LVL 58

Expert Comment

by:Julian Hansen
ID: 12306160
Don't have it yet - but let me see what I can do.
0
 

Author Comment

by:aslandk
ID: 12306165
perfect:):)
0
 
LVL 58

Expert Comment

by:Julian Hansen
ID: 12309054
Done,

That was not a lot of fun - quite frankly I prefer the C/C++ implementation - a lot simplier.

Anyway here it is

http://www.managedprofile.com/downloads/mpdefprnVB.zip

The archive contains a VB version of the mpdefprn.exe and the source code to create it.

As with the C/C++ version it is a command line utility you run in the TS session you want to set the default printer for.

Let me know how you get along.

Julian
0
 

Author Comment

by:aslandk
ID: 12309307
thanks...going home from work now....will look at it tomorrow....do the user need to run it everytime the user is logging on to citrix?

0
 
LVL 58

Expert Comment

by:Julian Hansen
ID: 12309493
Yes, probably - it depends how your profiles are set-up but I would recommend you run it at login (login script or startup director or Run key) or give the user an icon to run it. Remember this is a simple utility to demonstrate the functionality - if you want something a little more fancy you will need to modify it to suite your needs.
0
 
LVL 58

Accepted Solution

by:
Julian Hansen earned 250 total points
ID: 12537728
Aslandk,

How did you get on with the code I posted - did it work for you?

0

Featured Post

Want Experts Exchange at your fingertips?

With Experts Exchange’s latest app release, you can now experience our most recent features, updates, and the same community interface while on-the-go. Download our latest app release at the Android or Apple stores today!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Make the most of your online learning experience.
Simple Linear Regression
Starting up a Project

632 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question