Solved

Registry setting for default printer

Posted on 2004-04-28
13
19,693 Views
Last Modified: 2011-08-18
Hi,

What is the registry setting for the current selected default printer.
It is some kind of combination of printer-name, port all contained in a ','-seperated string.

For the port in case of a file-port.
*Is it possible to change the port-directory by changing the registry setting.
*Is the printer-definition also affected when the registry-setting is changed.
*And is it possible to force this registry setting to be a named file instead of a directory.

Thanx,
Alexander
0
Comment
Question by:aperdon
  • 6
  • 6
13 Comments
 
LVL 4

Expert Comment

by:scorpiia
ID: 10937107
HKey_Current_User\Printers
0
 
LVL 1

Author Comment

by:aperdon
ID: 10937330
Not something like this for the current printer? But this one doesnot exist in my Registry.

HKCU:Software\Microsoft\Windows NT\CurrentVersion\Windows\Device

But when I debug through some code which reads from registry it reads from group="Windows" item="Device".


Let me check at home (at work now without any registry privileges) what is in this registry-dir you specified. Is there only the printer-definitions there or also some info about current default printer.
0
 
LVL 21

Expert Comment

by:gemarti
ID: 10937437
Here is a script that uses WMI to set the default printer. Maybe it will help....
Set the Default Printer
http://www.microsoft.com/technet/community/scriptcenter/printing/scrprn44.mspx

+++++++Start Script+++++++++++
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colInstalledPrinters =  objWMIService.ExecQuery _
    ("Select * from Win32_Printer Where Name = 'ScriptedPrinter'")
For Each objPrinter in colInstalledPrinters
    objPrinter.SetDefaultPrinter()
Next
++++++++END SCRIPT+++++++++
0
 
LVL 21

Expert Comment

by:gemarti
ID: 10937471
This should be applicable in XP:

Changing a User's Default Printer in the Registry
http://support.microsoft.com/default.aspx?scid=kb;en-us;156212

SUMMARY
There are times when you want to change the default printer of a user or group of users without having access to the user's (or users') computer(s). You can do this by making a registry entry.

The information in this article applies to:
Microsoft Windows 2000 Server
Microsoft Windows 2000 Advanced Server
Microsoft Windows 2000 Professional
Microsoft Windows NT Workstation 3.5
Microsoft Windows NT Workstation 3.51

6/3/2003
0
 
LVL 21

Expert Comment

by:gemarti
ID: 10937502
BTW: The KEY that scorpia gives only directs you to the location that indicates what printers the user has set up, not the default printer. :(
0
 
LVL 1

Author Comment

by:aperdon
ID: 10937572
I dont have "HKCU\\Software\Microsoft\Windows NT\CurrentVersion\Windows:Device" in my registry in my XP. Yet I am able to query the registry for "Windows:Device" to get the current default printer. Very confusing. You have this key in ur XP registry?

Will the script as you provided work in VBA? Can I just use Get/Set ProfileString Win32 Api's to do the trick?

The "string" defined by Device denotes : <name>,<driver>,<port>

What can I do with this <port>. Can I force this port to send output to a named-filename.Or is <port> always a directory. Will changing the <port> part for the default printer afftect the printer settings as defined for the same named printer in HKCU\\Printers.

Indeed, I assumed that scorpia-s KEY only is for the printer definitions.

0
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
LVL 1

Author Comment

by:aperdon
ID: 10947118
You are right about the key. I found it. I cant see any reason why i did it not see it time over time..... Must have looked at 1000 times and always overlooked it.

I played around with the default printer key. Changing port part does not affect to which dir the output-file is written.
But however, there is a Port key inside the printer-definition key. I will try that one.

Do you have any experience with changing port-spool-directories?
0
 
LVL 21

Expert Comment

by:gemarti
ID: 10948910
>>Will the script as you provided work in VBA? Can I just use Get/Set ProfileString Win32 Api's to do the trick?
You can save it as a VBS script and it should run in XP with no problems. If you do have a problem then make sure the Windows Management Instrumentation Service is running (START | RUN | SERVICES.MSC)


>>What can I do with this <port>.
I think you can either send the print job to a local printer port, such as LPT1 or to a network shared printer. I think the only way to send a print job to a file is to select that option when prompted by the print dialog.

>>Do you have any experience with changing port-spool-directories?
Yes. It is a registry hack as well. You have to tell the system where the new spool directory is located.
0
 
LVL 21

Expert Comment

by:gemarti
ID: 10948936
To change the default printer spool directory
http://www.nthelp.com/351/spooldir.htm
0
 
LVL 1

Author Comment

by:aperdon
ID: 10948964
>>Do you have any experience with changing port-spool-directories?
Yes. It is a registry hack as well. You have to tell the system where the new spool directory is located.

So without creating a new port. Just change the Port key to whatever spool-dir. Right?
Can you share your experiences in this, especially if it comes to named-file spooling. That is: Can I specify an output-file-name in the Port-key and to force the spooler to write to that file.
0
 
LVL 1

Author Comment

by:aperdon
ID: 10949019
Ok. I see you posted another comment while I was typing mine.

Any experience with this SpoolDirectory? This is like 'Port' right, in case of a file-based port. SpoolDirectory probably wont be used by other type of port-printing like printing to for example to LPT1:.
0
 
LVL 21

Accepted Solution

by:
gemarti earned 100 total points
ID: 10950500
My only experience with SpoolDirectory is that on my print server I changed the spool directory to a different drive so as to not create problems on the drive that my system is installed on. I'm not exactly sure of what you are asking. If your wanting to print to file then I believe the file is stored in that spool file directory until it is released, but I'm not real sure about that.
0
 
LVL 1

Author Comment

by:aperdon
ID: 10950524
Ok. I will test it. Thanx for the new info sofar again.
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Down grade from Windows 8.1 to 7 NTLDR missing 9 157
move Windows 10 apps to diff disk 39 143
Windows 7 and Pro update issues 5 87
Error login w2012 domain 6 65
If your system is showing symptoms of browser hijacks or 'google search redirects' check out my other article (http://rdsrc.us/u3GP7A) first and run the tool TDSSKiller (http://rdsrc.us/GDBBs4) to get rid of the infection. Once done, and if the …
It is only natural that we all want our PCs to be in good working order, improved system performance, so that is exactly how programs are advertised to entice. They say things like:            •      PC crashes? Get registry cleaner to repair it!    …
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

920 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

15 Experts available now in Live!

Get 1:1 Help Now