Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Sometimes Error-message in vbscript (sheduled task)

Posted on 2011-09-15
2
Medium Priority
?
274 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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…
This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…

636 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