123FakeSt
IS-IT--Management
- Aug 4, 2003
- 182
I get an error "can't delete registry key" when running. I can delete it manually.
The early bird gets the worm, but the second mouse gets the cheese.
Code:
'--------------Main Function----------------
Dim FSo, logFile, objCmd, path, fileName
Set FSO = CreateObject("scripting.FileSystemObject")
Set WshShell = CreateObject("WScript.Shell")
'Create Log File and Write Header
Set logFile = FSO.CreateTextFile ("C:\Temp\HP_Removal.txt", True)
logFile.Write "HP Printer Port Removal Progress" & VBCrLf
logFile.Write "--------------------------------" & VBCrLf
'Stop Printer Service
WshShell.popup "Stopping Spooler Service" , 1 , "", 0
Set objCmd = WshShell.Exec("Net Stop Spooler")
Wscript.sleep 6000
'Rename the three HP dll files
fileName = "HPTcpMon.dll"
path = "C:\WINDOWS\system32\"
If FSO.fileexists(path & fileName) then
logFile.Write "System32 File Found and renamed" & VBCrLf
FSO.movefile path & fileName, path & filename & ".old"
Else
logFile.Write "System32 File NOT Found!!!!!!!!!!" & VBCrLf
End If
path = "C:\Program Files\Hewlett-Packard\HP Install Network Printer Wizard\portmon\nt40tcp\local\"
If FSO.fileexists(path & fileName) then
logFile.Write "nt40tcp File Found and renamed" & VBCrLf
FSO.movefile path & fileName, path & filename & ".old"
Else
logFile.Write "nt40tcp File NOT Found!!!!!!!!!!" & VBCrLf
End If
path = "C:\Program Files\Hewlett-Packard\HP Install Network Printer Wizard\portmon\win9xtcp\local\"
If FSO.fileexists(path & fileName) then
logFile.Write "nt40tcp File Found and renamed" & VBCrLf
FSO.movefile path & fileName, path & filename & ".old"
Else
logFile.Write "win9xtcp File NOT Found!!!!!!!!!!" & VBCrLf
End If
'Delete the Registry Folder
path = "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Monitors\HP Standard TCP/IP Port"
logFile.Write "Attempted Removing HP Registry Key"
WshShell.RegDelete path & "\"
'Start Spooler Service
WshShell.popup "Starting Spooler Service" , 1 , "", 0
Set objCmd = WshShell.Exec("Net Start Spooler")
Set FSo = nothing
Set logFile = nothing
The early bird gets the worm, but the second mouse gets the cheese.