[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3932
  • Last Modified:

Scripting take a printer offline/online XP

is there anyway (preferably from the command line i.e. DOS) to be able to take a printer offline or online under windows XP?

I have a number of scripts which currently set the firewall level, with offline and with exceptions being used only at home and everything being locked down on untrusted networks.

The printer is called "EPSON Stylus C82 Series (WiFi)", and windows treats it as a local printer although it is networked via LPD on my Belkin print server.

Ideally i would like the solution to work for proper networked printers as well (IPP/Cups and Samba/Windows) so i can use a simaler script at work.

(OS is Windows XP-SP2)
0
AcerKevUK
Asked:
AcerKevUK
  • 3
  • 3
1 Solution
 
masterbakerCommented:
I'm not sure if you want to pause printing or use the option to "Use Printer Offline".  I assume you want to pause the printer, so here's the difference in registry keys for pausing a printer:

The "Status" value changes from dword:00000180 to dword:00000181 in these three keys:

HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Printer\Printers\<printer name>
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Printer\Printers\<printer name>
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Print\Printers\<printer name>

You will need to check out these three keys in regedit.exe to find the exact name of your printer.  Are you familiar with regedit?  Hopefully!  You will need to export these three values to three different files.  Then you can open the first with notepad and copy over the other two settings.  Now save the file.  Now make a copy of this file and change the value to ...181 instead of ...180.  Save this file.

You can then use the reg command to import these settings.  Add this reg command to a batch file and you can then add a shortcut to it.  Whew!

Here's the reg commad line:

reg import <filename>

Please post back if you need more details.

Jeff
0
 
AcerKevUKAuthor Commented:
I actually wanted to "Use printer offline" so i can still "print" :as far as word et al are concered) while at uni, and when i get home a single doubleclick would "use printer online" and start printing my jobs out

I am familier with importing and expoting registry keys, it's just finding the right one (or other method of changing things) that i struggle with.
0
 
masterbakerCommented:
Oops, I guessed wrong! :)  Here are the correct changes to make then:

HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Printer\Printers\<printer name>
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Printer\Printers\<printer name>
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Print\Printers\<printer name>

Change value "ChangeID" from dword:0387216a to dword:03878def
Change value "Attributes" from dword:00001000 to dword:00001400

HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Hardware Profiles\0001\System\CurrentControlSet\Control\Print\Printers\<printer name>
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Hardware Profiles\0001\System\CurrentControlSet\Control\Print\Printers\<printer name>

Change value "PrinterOnLine" from dword:00000001 to dword:00000000

So a few more changes to make for this to work.  

By the way, if you ever need to figure this out in the future, I'll tell you my trick.  First off, you need a program called WinMerge (or another tool to compare differences between files).  You can get WinMerge here (it is freeware): http://winmerge.sourceforge.net/.

Now you need to export your entire registry file (or if you want to speed things up, only export HKLM or HKCU or whatever hive you think is affected).  Be sure to have regedit and the other program/activity up and ready to go before you do this.  If you make the change and then have to open regedit, it will flag other minor changes in the registry files and therefore cause more changes to show up between files.  Anyway, export the hive before the change and then again after the change.  Now open WinMerge and do a File >> Open and pick the before and after registry files.  Now you can click on the Merge menu and select "Next Difference".  Keep selecting the differences and recording the changes.  

After you do this a couple of times you'll get quite comfortable with the process.  It is a great way to find out how to manually manipulate the registry to do common tasks!

Jeff
0
Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

 
AcerKevUKAuthor Commented:
Thanks for the information, as a try i out i also used WinMerge and found the values were different, although the effected Keys were the same, i have therefore chosen to use my values.

For Online mode the values were :
"ChangeID"=dword:03fcfe8c
"Attributes"=dword:00000a00
"PrinterOnLine"=dword:00000001

"ChangeID"=dword:0400d626
"Attributes"=dword:00000e00
"PrinterOnLine"=dword:00000000

I've will also award an extra 100 points for the WinMerge tip off - thanks!

However for windows to take note of the changes you need to add the lines
net stop spooler
net start spooler
to your bat file after adding the registry entries.
0
 
AcerKevUKAuthor Commented:
In the previous comment the second set of values should hav been titled "and For Offline mode the values were" :
0
 
masterbakerCommented:
Ahh, guess I should have double checked with another computer to see if those values were different.  Good catch!  

I'm glad I was able to help out.

Jeff
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now