In bash, I would use
[ -w ... ]
What's the equivalent for Windows batch files?
In bash, I would use
[ -w ... ]
What's the equivalent for Windows batch files?
you can do it like this using vbscript
Set objFS=CreateObject("Scripting.FileSystemObject")
Set objArgs = WScript.Arguments
strFile = objArgs(0)
Set objFile = objFS.GetFile(strFile)
If Not objFile.Attributes And 1 Then
WScript.Echo "The file is Read/Write."
Else
WScript.Echo "The file is Read-only."
End If
save as check.vbs and on command line
c:\test> cscript //nologo check.vbs myfile
As far as I know, you can found out whether the file exists or not, but there's no way to know if it's writeable, apart from trying to write on it. It's not only a matter of not having the R flag; network and NTFS permissions are involved too.
If you can rewrite your code, you can capture the return code of the write operation trough the errorlevel.