#92600 - 2003-08-11 06:56 PM
Checking to see if File Is In Use
|
Lee Wilmott
Starting to like KiXtart
Registered: 2002-09-17
Posts: 106
Loc: Bristol, UK
|
I hope someone can help me...This topic may have come up before, but when I did a search I couldn't find anything...
Anyway...I would like to check to see if a particular file is in use. I CANNOT try and open the file for Read/Write access and test whether the return code is not zero.
Ideally I would like to search the list found in Computer Management (Windows 2000)..."System Tools\Shared Folders\Open Files" and look for a particular entry.
Is it possible to search this list?
Cheers guys,
Lee
|
Top
|
|
|
|
#92603 - 2003-08-12 11:02 AM
Re: Checking to see if File Is In Use
|
Lee Wilmott
Starting to like KiXtart
Registered: 2002-09-17
Posts: 106
Loc: Bristol, UK
|
Cheers Jens,
I am really struggling to try to manipulate CIM_DataFile.
Am I doing it correctly?
Here is my code...
code:
Dim $strFileName, $strComputer Dim $objWMIService, $colFiles, $objFile
CLS
$strFileName = "e:\\apakds\\apak\\sas\\action.ldb" $strComputer = "."
$objWMIService = GetObject("winmgmts:" + "{impersonationLevel=impersonate}!\\" + $strComputer + "\root\cimv2") $colFiles = $objWMIService.ExecQuery ("SELECT * FROM CIM_DataFile WHERE Name = '" + $strFileName + "'")
For Each $objFile in $colFiles ? "Name: " + $objFile.Name ? "File name: " + $objFile.FileName ? "InUseCount: '" + $objFile.InUseCount + "'" Next
If I look in Computer Management (Windows 2000)..."System Tools\Shared Folders\Open Files" I can see that this particular file has "4" locks.
However, when I run this code it returns the following...
code:
InUseCount: ''
Why doesn't it return "4". I would have expected a numerical value to be returned.
Can anyone help me?
Lee
|
Top
|
|
|
|
#92605 - 2003-08-12 04:41 PM
Re: Checking to see if File Is In Use
|
Lee Wilmott
Starting to like KiXtart
Registered: 2002-09-17
Posts: 106
Loc: Bristol, UK
|
Cheers Jens!
Thanks anyway!
Lee
|
Top
|
|
|
|
Moderator: Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart
|
1 registered
(Allen)
and 337 anonymous users online.
|
|
|