#158631 - 2006-03-09 07:48 PM
Re: How to check if a file is in use
|
Benny69
Moderator
Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
|
|
Top
|
|
|
|
#158633 - 2006-03-09 08:08 PM
Re: How to check if a file is in use
|
Benny69
Moderator
Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
|
if the file in question is a .exe it is a process
|
Top
|
|
|
|
#158637 - 2006-03-09 08:48 PM
Re: How to check if a file is in use
|
Benny69
Moderator
Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
|
if that is the case check out Inuse.exe. "InUse is a command-line tool that performs on-the-fly replacement of files currently in use by the operating system. You must be a member of the Administrators group to use this tool."
|
Top
|
|
|
|
#158641 - 2006-03-09 09:34 PM
Re: How to check if a file is in use
|
Allen
KiX Supporter
Registered: 2003-04-19
Posts: 4549
Loc: USA
|
I just found this... it's comes with XP... OpenFiles.exe
For it to check local files you first have to enable it by: Code:
openfiles /local on Then Reboot.
Once you restart then just issue the following command: Code:
openfiles /query
This is my output: Quote:
Files Opened Locally: ---------------------
ID Process Name Open File (Path\executable) ===== ==================== ================================================== 12 ati2evxx.exe C:\WINDOWS\system32 12 userinit.exe C:\Documents and Settings\Administrator 96 userinit.exe C:\..6595b64144ccf1df_6.0.2600.2180_x-ww_a84f1ff9 12 explorer.exe C:\Documents and Settings\Administrator 60 explorer.exe C:\..6595b64144ccf1df_6.0.2600.2180_x-ww_a84f1ff9 68 explorer.exe C:\..6595b64144ccf1df_6.0.2600.2180_x-ww_a84f1ff9 96 explorer.exe C:\..6595b64144ccf1df_6.0.2600.2180_x-ww_a84f1ff9 108 explorer.exe C:\..6595b64144ccf1df_6.0.2600.2180_x-ww_a84f1ff9 112 explorer.exe C:\..6595b64144ccf1df_6.0.2600.2180_x-ww_a84f1ff9 156 explorer.exe C:\..6595b64144ccf1df_6.0.2600.2180_x-ww_a84f1ff9 320 explorer.exe C:\..6595b64144ccf1df_6.0.2600.2180_x-ww_a84f1ff9 344 explorer.exe C:\..6595b64144ccf1df_6.0.2600.2180_x-ww_a84f1ff9 504 explorer.exe C:\Documents and Settings\Administrator\Desktop 512 explorer.exe C:\Documents and Settings\All Users\Desktop 516 explorer.exe C:\..\Application Data\Microsoft\CD Burning 596 explorer.exe C:\..\Microsoft\Internet Explorer\Quick Launch 668 explorer.exe C:\Documents and Settings\Administrator\Start Menu 728 explorer.exe C:\..6595b64144ccf1df_6.0.2600.2180_x-ww_a84f1ff9 752 explorer.exe C:\..6595b64144ccf1df_6.0.2600.2180_x-ww_a84f1ff9 772 explorer.exe C:\..\History\History.IE5\index.dat 780 explorer.exe C:\..\Content.IE5\index.dat 796 explorer.exe C:\..\Administrator\Cookies\index.dat 900 explorer.exe C:\..6595b64144ccf1df_6.0.2600.2180_x-ww_a84f1ff9 920 explorer.exe C:\..6595b64144ccf1df_6.0.2600.2180_x-ww_a84f1ff9 924 explorer.exe C:\..6595b64144ccf1df_6.0.2600.2180_x-ww_a84f1ff9 1032 explorer.exe C:\Documents and Settings\Administrator\PrintHood 1040 explorer.exe C:\..6595b64144ccf1df_6.0.2600.2180_x-ww_a84f1ff9 1088 explorer.exe C:\..6595b64144ccf1df_6.0.2600.2180_x-ww_a84f1ff9 1216 explorer.exe C:\Documents and Settings\All Users\Start Menu 80 CLI.exe C:\..6595b64144ccf1df_6.0.2600.2180_x-ww_a84f1ff9 228 CLI.exe C:\..\v1.1.4322\CONFIG\security.config.cch 240 CLI.exe C:\..\v1.1.4322\CONFIG\enterprisesec.config.cch 248 CLI.exe C:\..\v1.1.4322\security.config.cch 260 CLI.exe C:\..\cli.exe.c88dbd71.ini.inuse 364 CLI.exe C:\Program Files\ATI Technologies\ATI.ACE 444 CLI.exe C:\..6595b64144ccf1df_1.0.2600.2180_x-ww_522f9f82 884 CLI.exe C:\..\LOCALS~1\Temp\Perflib_Perfdata_774.dat 1368 CLI.exe C:\..6595b64144ccf1df_6.0.2600.2180_x-ww_a84f1ff9 12 msnmsgr.exe C:\Documents and Settings\Administrator 64 msnmsgr.exe C:\..6595b64144ccf1df_6.0.2600.2180_x-ww_a84f1ff9 68 msnmsgr.exe C:\..6595b64144ccf1df_6.0.2600.2180_x-ww_a84f1ff9 160 msnmsgr.exe C:\..6595b64144ccf1df_6.0.2600.2180_x-ww_a84f1ff9 424 msnmsgr.exe C:\Program Files\MSN Messenger\msnmsgr.exe 432 msnmsgr.exe C:\Program Files\MSN Messenger\msnmsgr.exe 440 msnmsgr.exe C:\Program Files\MSN Messenger\msnmsgr.exe 448 msnmsgr.exe C:\Program Files\MSN Messenger\msnmsgr.exe 632 msnmsgr.exe C:\..6595b64144ccf1df_6.0.2600.2180_x-ww_a84f1ff9 1148 msnmsgr.exe C:\..\Microsoft\SystemCertificates\My 1236 msnmsgr.exe C:\..\Content.IE5\index.dat 1256 msnmsgr.exe C:\..\Administrator\Cookies\index.dat 1264 msnmsgr.exe C:\..\History\History.IE5\index.dat 1292 msnmsgr.exe C:\..6595b64144ccf1df_6.0.2600.2180_x-ww_a84f1ff9 1360 msnmsgr.exe C:\..\Microsoft\Network\Connections\Pbk 12 Web2pop.exe C:\Documents and Settings\Administrator 80 Web2pop.exe C:\..6595b64144ccf1df_6.0.2600.2180_x-ww_a84f1ff9 12 msmsgs.exe C:\Documents and Settings\Administrator 16 msmsgs.exe C:\..6595b64144ccf1df_1.0.2600.2180_x-ww_522f9f82 28 msmsgs.exe C:\..6595b64144ccf1df_6.0.2600.2180_x-ww_a84f1ff9 68 msmsgs.exe C:\..6595b64144ccf1df_6.0.2600.2180_x-ww_a84f1ff9 96 msmsgs.exe C:\..6595b64144ccf1df_6.0.2600.2180_x-ww_a84f1ff9 376 msmsgs.exe C:\Program Files\Messenger\msmsgs.exe 384 msmsgs.exe C:\Program Files\Messenger\msmsgs.exe 392 msmsgs.exe C:\Program Files\Messenger\msmsgs.exe 12 reader_sl.exe C:\Documents and Settings\Administrator 60 reader_sl.exe C:\..6595b64144ccf1df_6.0.2600.2180_x-ww_a84f1ff9 12 SafeCfg.exe C:\..\NETGEAR\NETGEAR ProSafe VPN Client 64 SafeCfg.exe C:\..6595b64144ccf1df_6.0.2600.2180_x-ww_a84f1ff9 12 qbupdate.exe C:\..\Common Files\Intuit\QuickBooks\QBUpdate 68 qbupdate.exe C:\..6595b64144ccf1df_6.0.2600.2180_x-ww_a84f1ff9 92 qbupdate.exe C:\..6595b64144ccf1df_6.0.2600.2180_x-ww_a84f1ff9 468 qbupdate.exe C:\..\Content.IE5\index.dat 484 qbupdate.exe C:\..\Administrator\Cookies\index.dat 492 qbupdate.exe C:\..\History\History.IE5\index.dat 520 qbupdate.exe C:\..6595b64144ccf1df_6.0.2600.2180_x-ww_a84f1ff9 588 qbupdate.exe C:\..6595b64144ccf1df_6.0.2600.2180_x-ww_a84f1ff9 700 qbupdate.exe C:\..\Microsoft\Network\Connections\Pbk 12 SyncToy.exe C:\Program Files\Microsoft\SyncToy 80 SyncToy.exe C:\..6595b64144ccf1df_6.0.2600.2180_x-ww_a84f1ff9 228 SyncToy.exe C:\..\v1.1.4322\CONFIG\security.config.cch 240 SyncToy.exe C:\..\v1.1.4322\CONFIG\enterprisesec.config.cch 248 SyncToy.exe C:\..\v1.1.4322\security.config.cch 620 SyncToy.exe C:\..\Microsoft\SystemCertificates\My 656 SyncToy.exe C:\..\SyncToy.exe.7d71c9a.ini.inuse 660 SyncToy.exe C:\..6595b64144ccf1df_1.0.2600.2180_x-ww_522f9f82 676 SyncToy.exe C:\..6595b64144ccf1df_6.0.2600.2180_x-ww_a84f1ff9 712 SyncToy.exe C:\..\LOCALS~1\Temp\Perflib_Perfdata_70.dat 1232 SyncToy.exe C:\..6595b64144ccf1df_6.0.2600.2180_x-ww_a84f1ff9 84 OUTLOOK.EXE C:\..6595b64144ccf1df_6.0.2600.2180_x-ww_a84f1ff9 292 OUTLOOK.EXE C:\..\Microsoft\Outlook\outcmd.dat 380 OUTLOOK.EXE C:\My Documents\Email\outlook.pst 568 OUTLOOK.EXE C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\spambayes1.log 572 OUTLOOK.EXE C:\PROGRA~1\MICROS~2\Office\MSOUTL9.OLB 600 OUTLOOK.EXE C:\Program Files\Microsoft Office\Office\MSO9.DLL 652 OUTLOOK.EXE C:\..\Email\SpamBayes\default_bayes_database.db 656 OUTLOOK.EXE C:\..\Email\SpamBayes\default_message_database.db 660 OUTLOOK.EXE C:\Program Files\Common Files\System\Mapi\1033\NT 688 OUTLOOK.EXE C:\My Documents\Email\outlook.pst 752 OUTLOOK.EXE C:\..6595b64144ccf1df_6.0.2600.2180_x-ww_a84f1ff9 64 MAPISP32.EXE C:\..6595b64144ccf1df_6.0.2600.2180_x-ww_a84f1ff9 324 MAPISP32.EXE C:\Program Files\Common Files\System\Mapi\1033\NT 348 MAPISP32.EXE C:\..6595b64144ccf1df_6.0.2600.2180_x-ww_a84f1ff9 364 MAPISP32.EXE C:\..6595b64144ccf1df_6.0.2600.2180_x-ww_a84f1ff9 372 MAPISP32.EXE C:\..6595b64144ccf1df_6.0.2600.2180_x-ww_a84f1ff9 456 MAPISP32.EXE C:\..\Microsoft\Outlook\MSIN5300.RHC 480 MAPISP32.EXE C:\..\Microsoft\Outlook\MSIN2849.RHC 544 MAPISP32.EXE C:\My Documents\Email\outlook.pst 12 devldr32.exe C:\Documents and Settings\Administrator 60 devldr32.exe C:\..6595b64144ccf1df_6.0.2600.2180_x-ww_a84f1ff9 12 cmd.exe C:\Documents and Settings\Administrator 96 cmd.exe C:\..6595b64144ccf1df_6.0.2600.2180_x-ww_a84f1ff9 12 openfiles.exe C:\Documents and Settings\Administrator 1924 openfiles.exe C:\..6595b64144ccf1df_6.0.2600.2180_x-ww_a84f1ff9
Files Opened Remotely via local share points: --------------------------------------------- INFO: No shared open files found.
|
Top
|
|
|
|
#158643 - 2006-03-09 09:57 PM
Re: How to check if a file is in use
|
Allen
KiX Supporter
Registered: 2003-04-19
Posts: 4549
Loc: USA
|
Wsing WSHPipe I was able to check and see if my PST file was open.
Code:
break on
$output=wshpipe('openfiles /query',1) for each $line in $output if instr($line,"pst") ? $line endif next
Function WshPipe($ShellCMD, OPTIONAL $NoEcho) Dim $oExec, $Output $oExec = CreateObject("WScript.Shell").Exec($ShellCMD) If Not VarType($oExec)=9 $WshPipe="WScript.Shell Exec Unsupported" Exit 10 EndIf $Output = $oExec.StdOut.ReadAll + $oExec.StdErr.ReadAll If Not $NoEcho $Output Endif $WshPipe=Split(Join(Split($Output,CHR(13)),''),CHR(10)) Exit($oExec.ExitCode) EndFunction
|
Top
|
|
|
|
#158644 - 2006-03-09 10:08 PM
Re: How to check if a file is in use
|
Allen
KiX Supporter
Registered: 2003-04-19
Posts: 4549
Loc: USA
|
I hate making UDFs that are dependent on external EXEs, but this works too...
Code:
break on if isfileopen("outlook.pst") "File is Open" else "File is not Open" endif
function isfileopen($file) dim $output, $line $output=wshpipe('openfiles /query',1) for each $line in $output if right($line,len($file))=$file $isfileopen=1 endif next endfunction
Function WshPipe($ShellCMD, OPTIONAL $NoEcho) Dim $oExec, $Output $oExec = CreateObject("WScript.Shell").Exec($ShellCMD) If Not VarType($oExec)=9 $WshPipe="WScript.Shell Exec Unsupported" Exit 10 EndIf $Output = $oExec.StdOut.ReadAll + $oExec.StdErr.ReadAll If Not $NoEcho $Output Endif $WshPipe=Split(Join(Split($Output,CHR(13)),''),CHR(10)) Exit($oExec.ExitCode) EndFunction
|
Top
|
|
|
|
#158646 - 2006-03-10 01:37 PM
Re: How to check if a file is in use
|
Richard H.
Administrator
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
Quote:
if move fails, it's in use, right?
If the failure reason (@ERROR) is 32 or 33 then it's a reasonable assumption.
That's not a check if the file is in use though. A check would be non-intrusive.
|
Top
|
|
|
|
#158648 - 2006-03-10 04:54 PM
Re: How to check if a file is in use
|
Richard H.
Administrator
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
Logic suggests that there must be a table in the kernel somewhere - whether it is exposed as a scriptable API or not is another question
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 369 anonymous users online.
|
|
|