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
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 &
Set colInstalledPrinters = objWMIService.ExecQuery _
("Select * from Win32_Printer Where Network = TRUE")
For Each objPrinter in colInstalledPrinters
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
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
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?
Originally Posted by placky
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:
This doesn't use WMI so might help.
Set oPrinters = oNetwork.EnumPrinterConnections
For i = 0 to oPrinters.Count - 1 Step 2
if left(oPrinters.Item(i+1),2)="\\" then
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:
Last Post: 26th January 2009, 10:37 PM
By roland in forum How do you do....it?
Last Post: 20th September 2007, 09:43 PM
By contink in forum How do you do....it?
Last Post: 31st March 2007, 10:12 PM
By Mintsoft in forum Windows
Last Post: 27th February 2006, 03:33 PM
By woody in forum Scripts
Last Post: 27th November 2005, 10:41 PM
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)