[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

08/10/2009 at 10:34AM PDT, ID: 24640673
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.8

WSH error: cannot find the file specified. What am I doing wrong?

Asked by mcooper13 in Windows Programming, VB Script, Windows Batch Scripting

Tags: WSH, 80070002, folder watch

Hey guys,

I'm having an issue with a script I've been working on that watches a folder for new files and then sends an e-mail when it finds a new file. It works perfectly when run manually from the command prompt or when scheduled in windows task scheduler. However, there are about 30 people in the office who each have a folder that needs to be watched so they can be notified when a new file is added to the folder. Since I'd prefer not to have to schedule the script for each of the folders 30 times, I wrote what I thought would be a simple batch file to launch the script for each user that could then be scheduled in the task scheduler. The batch file, launches the folder watching script without a hitch, but once a new file is added to the folder being watched I get the following error from the windows script host:

Script: G:\faxes\Fax Notify\user1\folderWatcher.vbs
Line: 18
Char: 5
Error: The system cannot find the file specified.
Code: 80070002
Source: (null)

Here are the other relevant script files:
folderWatcher.vbs:
'This script watches a folder and then runs the faxNotify program when a new file is found

Set objShell = CreateObject("Wscript.Shell")

strComputer = "."

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set colMonitoredEvents = objWMIService.ExecNotificationQuery _
    ("SELECT * FROM __InstanceCreationEvent WITHIN 10 WHERE " _
        & "Targetinstance ISA 'CIM_DirectoryContainsFile' and " _
            & "TargetInstance.GroupComponent= " _
                & "'Win32_Directory.Name=""G:\\\\faxes\\\\eugenem""'")
            'modify the folder name to match the directory being watched

Do
    Set objLatestEvent = colMonitoredEvents.NextEvent
    objShell.Run("faxNotify.bat ")
Loop

runFolderWatcher.bat - Batch file that launches the folderWatcher program for each user:
start wscript "G:\faxes\Fax Notify\user1\folderWatcher.vbs"
start wscript "G:\faxes\Fax Notify\user2\folderWatcher.vbs"
start wscript "G:\faxes\Fax Notify\user3\folderWatcher.vbs"
start wscript "G:\faxes\Fax Notify\user4\folderWatcher.vbs"

The faxNotify.bat file is in the same folder as folderWatcher.vbs. When run manually from the command prompt or scheduled in the task scheduler it works perfectly. I've tried hard-coding the path of the faxNotify.bat file in the folderWatcher.vbs file and get the same error. Does anyone know what I'm doing wrong? Thanks.
[+][-]08/10/09 10:46 AM, ID: 25062179

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08/10/09 10:56 AM, ID: 25062274

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08/10/09 11:38 AM, ID: 25062644

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08/10/09 12:01 PM, ID: 25062909

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08/10/09 02:06 PM, ID: 25064070

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08/10/09 08:40 PM, ID: 25066025

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Windows Programming, VB Script, Windows Batch Scripting
Tags: WSH, 80070002, folder watch
Sign Up Now!
Solution Provided By: RobSampson
Participating Experts: 3
Solution Grade: A
 
 
[+][-]08/11/09 06:24 AM, ID: 25068707

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08/11/09 03:58 PM, ID: 25074320

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20090824-EE-VQP-74 - Hierarchy / EE_QW_3_20080625