Hi Rick,
You can go to this web site to get WMI events and the sample script below
alerts you about events. Just save the script and test it.
Bruce
http://msdn.microsoft.com/en-us/library/aa394554(v=vs.85).aspx
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" _
& strComputer & "\root\CIMV2")
Set objEvents = objWMIService.ExecNotificationQuery _
("SELECT * FROM Win32_ProcessTrace")
Wscript.Echo "Waiting for events ..."
i = 0
Do Until i=5
Set objReceivedEvent = objEvents.NextEvent
'report an event
Wscript.Echo "Win32_ProcessTrace event occurred" & VBNewLine _
& "Process Name = " _
& objReceivedEvent.ProcessName & VBNewLine _
& "Process ID = " _
& objReceivedEvent.Processid & VBNewLine _
& "Session ID = " & objReceivedEvent.SessionID
i = i+ 1
Loop
Sent: Saturday, April 09, 2011 11:01 AM
Subject: Re: Checking File State in VBS
I don't see a property or method in the FileSystemObject for it, but
since you're managing the file yourself, you can always keep a
variable that holds the state and updates when you open/close the
file.
But if you're looking to know if something else has the file open, you
have a trickier situation on your hands I think. WMI services may
give you a way to do that, as might running a Net command as a
subprocess. The latter is probably too messy to be worth it though,
and off the top of my head, I don't know how to use WMI to find out if
a file is open by another process. But the answer to that problem,
figuring out if anything has a file open, is more a question of what
the OS will let you do than what Window-Eyes or the FileSystemObject
will let you do.
On Sat, Apr 09, 2011 at 10:41:53AM -0400, RicksPlace wrote:
Hi: I have a file I created using the File System Object. I want to
check the File's state.
Is it opened, Closed or something else.
What Property or methods allow checking a file's state in VBS?
I haven't found anything yet Googling.
So, if you know anything about checking file state could you point me
in the right direction?
Thanks:
Rick USA
--
Doug Lee, Senior Accessibility Programmer
SSB BART Group - Accessibility-on-Demand
mailto:[email protected] http://www.ssbbartgroup.com
"While they were saying among themselves it cannot be done,
it was done." --Helen Keller