1
votes

I have a VBScript that does a number of tasks, including moving files from one place to another.

Lots of copy/move/create folder/delete folder/delete files like this

Set filesys = CreateObject("Scripting.FileSystemObject")
filesys.CopyFile "D:\Test Now\test.txt", "W:\test_2\test.txt"

I'm able to get the entire script to work when I run it manually by double clicking it and no errors come up. However, when I run it from scheduled task an error is shown "Path Not Found". I found this error by writing this error to a DB.

If

ON ERROR RESUME NEXT 

is off the script is stuck in that error. With it set to on, the script would skip the operations not carry out its function.

I've quadruple checked the paths to make sure its right. Is there something I should be aware of when running scripts with scheduled tasks?

3
What does it say when you type dir "D:\Test Now\test.txt" and dir "W:\test_2\" at the command line? - Jean-François Corbett

3 Answers

1
votes

Are D:\ And W:\ local drives, or are they mapped network drives? If they're mapped, the user running the process might not have those drives available. Be sure you run the task as a privileged local account. It's also best to log in to that account and run the command manually. Once you verify that it works, then you can tighten up security if that's a concern.

0
votes

This jumps to mind: enclose your paths in quotes ". One of the two has a space in it. And VBSscript certainly won't like that.

filesys.CopyFile "D:\Test Now\test.txt", "W:\test_2\test.txt"

Yup, just tested it, and that is indeed what was causing the error.

By the way, you may know this, but unless you want to enter a debugging nightmare, you shouldn't use On Error Resume Next unless you have a very specific reason to do so .

0
votes

An old topic I know, but this may help someone:

My scheduled task was running under a specific user. Using the component services snap in for MMC I needed to give the user 'Launch and activation' permissions. Once this was done, the scheduled task ran correctly.