开发者

Monitoring File Changes

Call CreateObject("WScript.Shell").Run(some.exe,0,False)

I'm using that line to call a .exe that returns some text, but can also write it to 开发者_StackOverflow社区a file.

I would use .Exec instead of .Run to get the results directly but then the script hangs.

I really don't want a timer checking if the output file is created or modified.

What I need is a way to catch an event somehow. Any Ideas?


Since you mention that it might either return it or write it to a file, does that mean that after the process has written to the file it'll exit?

If so, you could just call the Shell.Run method with the bWaitOnReturn parameter set to True and your script would wait for the process to finish before it continued.

Otherwise, if the process might write a file and then still continue to run, then I think you will have to poll to check if it exists, or possibly you could create a C# or VB.Net exe that uses FileSystemWatcher (or a normal Win32 exe that uses the API FindFirstChangeNotification) to look for the creation of the file and when it finds one it immediately exists and then you could run that process with bWaitOnReturn set to True, but that's probably just overcomplicating things.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜