?
Solved

Sometimes Error-message in vbscript (sheduled task)

Posted on 2011-09-15
2
Medium Priority
?
253 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
[X]
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
2 Comments
 
LVL 38

Accepted Solution

by:
Gerwin Jansen, EE MVE earned 500 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Recently I finished a vbscript that I thought I'd share.  It uses a text file with a list of server names to loop through and get various status reports, then writes them all into an Excel file.  Originally it was put together for our Altiris server…
Well hello again!  Glad to see you've made it this far without giving up.  In this, the fourth installment of my popular series, I'm going to cover functions and subroutines, what they are, and why they are useful.  Just in case you stumbled onto th…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

752 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