Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script to delete mapped printers from a server

Status
Not open for further replies.

br0ck

MIS
Apr 25, 2002
467
US
im looking for a script to delete any print queue from a perticular server

we are disableing an old print server and replacing it with another and i need to delete all the old queues from the workstations


any ideas

thanks-

MITS_Sig.gif
 
markdmac

Thank you

This is a very similar to the login script I already have in place

i added your network priner deletion section to mine (thanks!)

i have one other question i hope you might be able to answer

Like many other EnumNetworkDrives collection scripts i have come across they always fail on login from a GPO

Code:
Set clDrives = WshNetwork.EnumNetworkDrives
For i = 0 to clDrives.Count -1 Step 2
    WSHNetwork.RemoveNetworkDrive clDrives.Item(i), True, True
Next 

'Give the PC time to do the disconnect, wait 300 milliseconds
wscript.sleep 900
'Map drives and printers needed by all
'Note the first command uses the user name as a variable to map to a user share.
WSHNetwork.MapNetworkDrive "U:", "\\Data\users$\" & UserString,True
WSHNetwork.MapNetworkDrive "S:", "\\data\Coinc$",False
This code alwase fails on WSHNetwork.MapNetworkDrive "U:", "\\Data\users$\" & UserString,True



I took your code (above) and put it in to my script as well as test a modified version of your script and it works testing from the file however I run the login scripts via GPO and it always fails

If I enable "on error resume next" it looks to run as normal but skips other sections of the script

any advice?

Btw: are any of the scripts from your site available?


MITS_Sig.gif
 
I run the login scripts via GPO and it always fails
Do you receive any errors? How were the drives set up originally? I have seen problems in the past where mappings that were done manually get "stuck" and need to be removed from the registry. Can you manually disconnect the drive? If so what happens when you then run the script via GPO? Why don't you share the user folders directly?

Code:
On Error Resume Next
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set WshShell = CreateObject("Wscript.Shell")
Set oFolder = objFSO.GetFolder("E:\Shares")

Set oSubfolders = oFolder.SubFolders

For Each oSubFolder In oSubFolders
	cmdString ="net share " & oSubFolder.name& "=E:\Shares\" & oSubFolder.name& " /GRANT:" & oSubFolder.name &",FULL"
	WshShell.Run("CMD.EXE /C " & cmdString)
Next
If Err.Number <> 0 Then
	Wscript.Echo "A problem was encountered sharing folders"
Else
	Wscript.Echo "Folders shared successfully"
End If

You will always want to have [blue]On Error Resume Next[/blue] turned on for your login script, otherwise any error will stop script execution.

Btw: are any of the scripts from your site available?
The scripts listed on my site are contained within my Admin Script Pack and are available to my customers. A one time subscription gets you lifetime of updates to the Admin Script Pack. Please use the contact information from the site to discuss further if you have any questions regarding those scripts.

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top