I need to know that before any attempt to do anything with such file.
相关问题
- xcopy include folder
- Batch file if string starts by
- Jenkins - cmd is not recognized
- softlinks atime and mtime modification
- String Manipulation with case sensitivity
相关文章
- How do I get to see DbgPrint output from my kernel
- Compile and build with single command line Java (L
- Extracting columns from text file using Perl one-l
- How to update command line output?
- How to execute another python script from your scr
- How can one batch file get the exit code of anothe
- How to make jenkins fail at a failing windows batc
- Problems using start-process to call other powersh
Incidentally, dbenham's solution also seems to be an effective way to find out if a process is running. It was the best solution I found for the following application:
If you download and install the Windows Server 2003 Resource Kit Tools there is a utility called
oh.exe
that will list open file handles for a given file:http://www.microsoft.com/en-us/download/details.aspx?id=17657
Once you install it, reboot your machine and you'll be able to use the utility. You can see all the options in the Help and Support center as well as by typing
oh /?
in the command prompt.(Info from : http://windowsxp.mvps.org/processlock.htm )
Just i want to share with you an example of my script based on @dbenham's trick
Description of this script : Check_Locked_Files.bat : This script can scan and check for locked files on a set of folders that can be modified into the script; for example, i have chosen those set of folders to be scanned :
The output result is in HTML format for more readability.
If the file is locked we show it in red color otherwise we show it in green color.
And the whole script is : Check_Locked_Files.bat
In case you want to use this in a Cygwin Bash, here are the one-liners:
In addition to great answer from dbenham, the following form finally help me understand used technique:
type nul
command gives an empty output and does not affect the current echo setting likeecho off
command in orginal.If you want to use
if–then–else
condition remember of correct order - success statement (&&
) is going first and alternate statement (||
) is going second: