Windows Thread, Logoff Script problems and GPO in Technical; Hello everyone!
I have been having a problem with one laptop running a .VBS script when a user logs off ...
-
27th March 2008, 03:51 PM #1 Logoff Script problems and GPO
Hello everyone!
I have been having a problem with one laptop running a .VBS script when a user logs off it. The script below is set to run at log off via GPO and it works great on all the other laptops/PCs we have here. Unfortunately theres always one...
_________________________
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer &
"\root\cimv2")
Set colInstalledPrinters = objWMIService.ExecQuery _
("Select * from Win32_Printer Where Network = TRUE")
For Each objPrinter in colInstalledPrinters
objPrinter.Delete_
Next
_________________________
Has anyone got any ideas as to how I can add a form of try/catch statement to this so it just quits if it errors? At the moment its just sitting there running scripts until it reaches 10mins and times out!
Any help would be greatly appreciated
regards
Gareth
-
-
IDG Tech News
-
27th March 2008, 03:55 PM #2 Well if it runs on everything else, then there's clearly something up with that laptop. You could try re-imaging, it might be quicker than trying to work out the problem?
The script looks absolutely fine from my point of view
-
-
27th March 2008, 04:31 PM #3 
Originally Posted by
placky
_________________________
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer &
"\root\cimv2")
Set colInstalledPrinters = objWMIService.ExecQuery _
("Select * from Win32_Printer Where Network = TRUE")
For Each objPrinter in colInstalledPrinters
objPrinter.Delete_
Next
_________________________
Gareth
WMI can cause this problem as there is no 'time out' as such; it just sits there for ages until it gives up. You could try restarting WMI services (and Windows Firewall/ICS) before setting objWMIService?
-
-
27th March 2008, 06:03 PM #4 Plan B might be to do it differently; presumably, you just want to make sure that you have a "clean" start at each logon in terms of network printers?
I use the code below to get the list of network printers and remove them:
Code:
set oNetwork=createobject("wscript.network")
Set oPrinters = oNetwork.EnumPrinterConnections
For i = 0 to oPrinters.Count - 1 Step 2
if left(oPrinters.Item(i+1),2)="\\" then
onetwork.removeprinterconnection oPrinters.Item(i+1)
end if
Next This doesn't use WMI so might help.
A problem with WMI is that the repository can get messed up - Reseting WMI has a section "Resetting WMI" which shows you how to fix it.
-
Thanks to srochford from:
SHARE: 
Similar Threads
-
Replies: 3
Last Post: 26th January 2009, 10:37 PM
-
By roland in forum How do you do....it?
Replies: 11
Last Post: 20th September 2007, 09:43 PM
-
By contink in forum How do you do....it?
Replies: 8
Last Post: 31st March 2007, 10:12 PM
-
By Mintsoft in forum Windows
Replies: 3
Last Post: 27th February 2006, 03:33 PM
-
By woody in forum Scripts
Replies: 7
Last Post: 27th November 2005, 10:41 PM
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules