Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

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

remotely delete windows 98 printers

Hello,

I was wondering if anyone knows of a way to remotely delete printers in windows 98?
I need to do this with a large number of machines, and hope to do it by scripting eg in a login script or some scripting language, rather than manual labour.

thanx,
Shaun
0
sbradley2002
Asked:
sbradley2002
  • 3
  • 2
  • 2
1 Solution
 
war1Commented:
Greetings, sbradley2002!
   Where you looking for a program like PC Anywhere?

Best wishes, war1
0
 
war1Commented:
sbradley2002,
   Here is a free remote desktop Tridia VNC

http://www.tridiavnc.com/
0
 
sbradley2002Author Commented:
I already have vnc on the network.
This approach would still take considerable labour, someone sitting at a desk for hours on end.
I was looking for a scripted, behind-the-scenes, as the user logs on approach.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
BillDLCommented:
I think there would be a possibility of editing the registry, but are you trying to remove the SAME printer applet from ALL computers, or will you be removing other ones as well.

Doing a brief search in my registry using the exact name used by the applet in Control Panel > Printers > Epson Stylus COLOR 760, reveals the most obvious key:

HKEY_LOCAL_MACHINE\Config\0001\System\CurrentControlSet\Control\Print\Printers

the "Default" StringValue has the DataValue "Epson Stylus COLOR 760"

This key also has a sub-key named "Epson Stylus COLOR 760" with the "Default" value set to [value not set].

There are as many named folders here as there are printers in the Control Panel > Printers folder, so I would hazard a guess that by resetting the "Default" value to another printer name and leaving that sub-key intact, and by deleting the sub-key for the printer you want to remove, then this might remove the item from the "Printers" folder and set the other one as the default printer which will then be recognised by different applications needing a default printer.

I assume that you could call a .REG file from autoexec.bat or from the server to make the changes, but I think you would have to first copy some details from your system's registry to verify the details.

For instance, there is also the following registry key on my PC with details of this printer:

HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Print\Printers\EPSON Stylus COLOR 760

I will create a phantom printer on my Windows 98 machine and see if, by deleting the relevant registry key, the printer can be removed and another printer set as the default.
0
 
sbradley2002Author Commented:
I will be trying to remove the same printer applet from all computers (if that printer exists on that computer of course)
The logic would be something like
If printer "printername" exists
     remove printer
endif
Have you run your test yet?
0
 
sbradley2002Author Commented:
OK,
I ended up created my own inf file, and running it in the login script that everyone had.
Look at ms kb article 171424 and in msdn for instructions on how to do this.
Deleting the registry keys was not enough in windows 98, had to also removed lines from the win.ini to get rid of the printer.
That's all I did.
If I wanted to do this properly I should also track down the files used by each printer, and use the inf file to remove them as well.  The file below deletes 2 printers every time it is run in the login script.  For other printers there may be way more registry entries or win.ini lines to remove.
I run the inf file using this line in the logon scripts -
rundll setupx.dll,InstallHinfSection RunIt 0 \\srvr\share\delprn.inf

Here is the inf file I use...
;--------------------------------------------
; This file called  Delprn.INF deletes the printers
; under the [RegChange] section.  This one deletes entries representing defunct printers
; also erases win.ini entries in the EraseWinINIEntry's representing defunct printers

[Version]
signature="$CHICAGO$"

[DefaultInstall]
DelReg = RegChange
UpdateInis = EraseWinINIEntrys

[RunIt]
DelReg = RegChange
UpdateInis = EraseWinINIEntrys

;HKCR is short for HKEY_CLASSES_ROOT
;HKCU is short for HKEY_CURRENT_USER
;HKLM is short for HKEY_LOCAL_MACHINE
;HKU is short for HKEY_USERS

[RegChange]
HKCU,Software\Microsoft\Windows\CurrentVersion\Explorer\Printers,"Admin Gnd Flr HP DJ 540"
HKLM,Config\0001\System\CurrentControlSet\Control\Print\Printers\"Admin Gnd Flr HP DJ 540"
HKLM,System\CurrentControlSet\Control\Print\Printers\"Admin Gnd Flr HP DJ 540"
HKLM,System\CurrentControlSet\Control\Print\Environments\"Windows 4.0"\Drivers\"Admin Gnd Flr HP DJ 540"
HKCU,Software\Microsoft\Windows\CurrentVersion\Explorer\Printers,"Finance OKI Microline 591"
HKLM,Config\0001\System\CurrentControlSet\Control\Print\Printers\"Finance OKI Microline 591"
HKLM,System\CurrentControlSet\Control\Print\Printers\"Finance OKI Microline 591"

[EraseWinINIEntrys]
c:\windows\win.ini, Devices, "Admin Gnd Flr HP DJ 540=*",
c:\windows\win.ini, PrinterPorts, "Admin Gnd Flr HP DJ 540=*",
c:\windows\win.ini, Ports, "\\srvr\AdminGndFlrHPDJ540=*",
c:\windows\win.ini, Devices, "Finance OKI Microline 591=*",
c:\windows\win.ini, PrinterPorts, "Finance OKI Microline 591=*",
c:\windows\win.ini, Ports, "\\srvr\AdminGndFlrOKIMicroline591=*",
;-------------------------

cya,
Shaun
0
 
BillDLCommented:
My god, that was quick Shaun, I've just started to create a hypothetical batch file to do the job.  I feel kind of guilty that you've actually solved this one yourself. I work nights and just got up a while ago, you see.

What I intended doing was to first call the printer software uninstall files from the command line if they existed, allow them to run, force a reboot, and then cleanup and reset registry entries if they existed by calling the batch file again.

I recalled seeing a programme which would automate much of the work, but had to find the url again. There's a version for Windows 98 as well.

http://www.eytcheson.com/faq.htm
Multi Remote Registry Changer  (MRRC)
http://www.eytcheson.com/download.htm

It's not as easy using the command line to delete registry entries in 98 as with NT which has its own tools such as REG.EXE, REGCHG.EXE, REGFIND.EXE, REGINI.EXE, REGDMP.EXE etc from the resource kit supplement.

I remembered seeing a Visual Basic/Windows Scripting code to do the job and managed to find it again (must remember to bookmark these things in future). It might be of assistance to you at some point in the future:

http://www.mvps.org/serenitymacros/help.html

Their explanation:
-------------------

RegDelete.vbs
As it is not possible to delete keys or values using .REG files, this is a small vbs program that deletes keys or values from the registry.

Syntax
--------
[path] RegDelete [Key] | [Value]

Code:
-----------
'RegDelete.vbs
'Deletes keys or values from the registry.
'
'Serenity Macros       http://www.angelfire.com/biz/serenitymacros
'David Candy      davidc@sia.net.au
'
On Error Resume Next
vbPara=vbCRLF & vbCRLF
strExplain="RegDelete deletes keys and values from the registry." & vbPara & "Keys must end with a backspace and values must not." & vbPara & "Start without parameters to type in a key or value to delete, or place the key or value on the command line (use inverted commas to surround the key or value if it contains spaces)."  & vbPara & "Continue"
strTitle="Reg Delete"
Key=""
Dim silent
Silent=""

Dim Sh
Set Sh = WScript.CreateObject("WScript.Shell")
ReportErrors "Creating Shell"

Key=GetKey()
If Key<>"" then
      B=Sh.RegRead (Key)
      If Err.Number=0 Then
            Sh.RegDelete Key
            If Err.Number =0 Then
                  If silent<>"yes" Then MsgBox Key & " deleted", vbOKOnly + vbInformation, strTitle
            Else
                  ReportErrors "DeletingKey"
            End If
      Else
            If Err.Number=-2147024893 then
                  Err.Clear
                  MsgBox Key & " didn't exist", vbOKOnly + vbCritical, strTitle
            Else
                  ReportErrors "Reading before Deleting Key"
            End If
      End If
End If

ReportErrors "Main"
VisitSerenity

Function GetKey()
      Dim Ag
      Set Ag=Wscript.Arguments
      ReportErrors "Creating Aguments"
      If Ag.Count=1 then GetKey=Ag(0)
      Silent="yes"
      If Ag.Count >1 then sgBox "Too many parameters on command line. Try enclosing the key in a space",vbOKOnly + vbCritical, strTitle

      If Ag.Count=0 then
            If MsgBox (strExplain, vbYesNo + vbInformation, strTitle)=6 Then
                  GetKey=InputBox ("Enter the value or key to delete." & vbPara & "Keys must end in a backspace.", strTitle, strNamet1)
            End If
      End If
End Function

Sub ReportErrors(strModuleName)
      If err.number<>0 then Msgbox "Error occured in " & strModuleName & " module of " & err.number& " - " & err.description & " type" , vbCritical + vbOKOnly, "Something unexpected"
      Err.clear
End Sub

Sub VisitSerenity
      Dim Ag
      Set Ag=Wscript.Arguments
      If Ag.Count<>1 then
            If MsgBox("This program came from the Serenity Macros Web Site" & vbCRLF & vbCRLF & "Would you like to visit Serenity's Web Site now?", vbQuestion + vbYesNo + vbDefaultButton2, "Visit Serenity Macros") =6 Then
            sh.Run "http:\\www.angelfire.com\biz\serenitymacros"
            End If
      End If
End Sub
------------

I really don't feel I can accept the points because, the way I look at it, you have done a splendid job which is probably superior to my batch file thoughts so far, and my way would have probably left more to cleanup than yours.  It would also have taken me somewhat longer to test out safely.  I assume you have a number of "guinea pig" workstations at your disposal, whereas mine would have been purely hypothetical without this facility at my disposal.
0

Featured Post

Industry Leaders: 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!

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