Solved

copy default printer from remote machine

Posted on 2004-10-11
15
249 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
  • 8
  • 7
15 Comments
 
LVL 51

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
 
LVL 51

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 51

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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 51

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 51

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 51

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 51

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 51

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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

706 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now