Solved

Sometimes Error-message in vbscript (sheduled task)

Posted on 2011-09-15
2
241 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 37

Accepted Solution

by:
Gerwin Jansen 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This is an addendum to the following article: Acitve Directory based Outlook Signature (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_24950055.html) The script is fine, and works in normal client-server domains…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

760 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now