+ Post New Thread
Results 1 to 4 of 4
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 ...
  1. #1
    placky's Avatar
    Join Date
    Feb 2008
    Location
    N wales
    Posts
    27
    Thank Post
    3
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    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

  2. #2

    Michael's Avatar
    Join Date
    Dec 2005
    Location
    Birmingham
    Posts
    9,266
    Thank Post
    242
    Thanked 1,575 Times in 1,254 Posts
    Rep Power
    341
    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

  3. #3
    altecsole's Avatar
    Join Date
    Jun 2005
    Location
    Whittington, Lancashire
    Posts
    286
    Thank Post
    40
    Thanked 36 Times in 26 Posts
    Rep Power
    26
    Quote Originally Posted by placky View Post
    _________________________
    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?

  4. #4

    Join Date
    Aug 2005
    Location
    London
    Posts
    3,157
    Thank Post
    116
    Thanked 529 Times in 452 Posts
    Blog Entries
    2
    Rep Power
    124
    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.

  5. Thanks to srochford from:

    placky (28th March 2008)

SHARE:
+ Post New Thread

Similar Threads

  1. logoff script to delete registry key
    By ICMC in forum Scripts
    Replies: 3
    Last Post: 26th January 2009, 10:37 PM
  2. Delete Profile on LogOff
    By roland in forum How do you do....it?
    Replies: 11
    Last Post: 20th September 2007, 09:43 PM
  3. Auto logoff by GPO?
    By contink in forum How do you do....it?
    Replies: 8
    Last Post: 31st March 2007, 10:12 PM
  4. CC3 Workstations seem to hang on logoff
    By Mintsoft in forum Windows
    Replies: 3
    Last Post: 27th February 2006, 03:33 PM
  5. 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
  •