Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Sometimes Error-message in vbscript (sheduled task)

Posted on 2011-09-15
2
245 Views
Last Modified: 2012-05-12
Hi everyone,

For some time now I have been using a vbscript to automatically close idle sessions to a XP-host in my network. It acts as a FTP-server and people use it a lot to access shared folders. After some open sessions, some clients can't connect anymore to the shared folders. The script cleares the connections of the users which doesn't have any open files.

I have the feeling that the script doesn't work anymore and sometimes an error-message appears. It is actually random when the script runs. I have set this to run every 5 minutes.

I hope you can help me resolve this. I have enclosed the error message on my server and the vbscript.

Thanks in advance!
Set dResources = CreateObject("Scripting.Dictionary")
Set oConnection = GetObject("WinNT://DT_A2O_XW6200_1/LanmanServer")

Set cResources = oConnection.Resources
For Each oResource in cResources
    If Not dResources.Exists(LCase(oResource.User)) Then dResources.Add LCase(oResource.User), 1
Next
Set cResources = Nothing


Set cSessions = oConnection.Sessions
For Each oSession in cSessions
    If Not dResources.Exists(LCase(oSession.User)) Then _
        cSessions.Remove(oSession.Name)
Next
Set cSessions = Nothing

Set oConnection = Nothing
Set dResources = Nothing

Open in new window

Script-error.png
0
Comment
Question by:Silencer001
2 Comments
 
LVL 38

Accepted Solution

by:
Gerwin Jansen, EE MVE earned 125 total points
ID: 36546207
Hi, it looks like the session has already disappeared the moment you are trying to close it.

You could add some basic error handling by adding "On Error Resume Next" at the begin of your script. That will ignore the error and continue your script.

If you're interested in how may times things go wrong, add some code after the csessions.Remove statement, like writing date,time, session name etc. to a file.

When for some reason, your script stops functioning at all, you'd have to comment out the On Error ... statement to see the errors again.
0
 

Author Comment

by:Silencer001
ID: 36558907
Thanks for the answer gerwinjansen. I just added the "On error resume next" and will see how it goes. I also removed the old sheduled task and made a new one. At the first glance, everything is going good at the moment. Thanks!
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to writing scripts for a Client/Server computing environment it is essential to consider some way of enabling the authentication functionality within a script. This sort of consideration mainly comes into the picture when we are dealin…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question