Jump to content

How to detect if file is "Blocked"?


qwert
 Share

Recommended Posts

I've researched the issue of "file blocking" that the operating system commonly does when files are downloaded from the Internet.  And I've now used an example script from the help file to "enumerate the streams" for a file whose properties indicate "Blocked" ... which seems to be recommended way to get at the parameter.

My problem is that I haven't been able to bridge between the examples msdn provides ( msdn blog examples ) and the result of the _WinAPI_EnumFileStreams script (see below).  Zone.Identifier is apparently the file parameter to check, but they also mention $Data.

What test can I use to determine that a file is blocked?  Or is there a more direct way to determine that?

Thanks in advance for any help.

 

Zone Identifier.JPG

Link to comment
Share on other sites

Thanks for your response.

Actually, I had noticed that script, but couldn't determine how it was using _WinAPI_DeleteFile ... or why, for that matter:

If FileExists($aCmdLine[$i] & ":Zone.Identifier") Then
   ConsoleWrite ( "Unblocking file " & $aCmdLine[$i] & @CRLF )
   _WinAPI_DeleteFile($aCmdLine[$i] & ":Zone.Identifier:$DATA")
EndIf

Anyone know of documentation that explains the call's syntax?

(BTW, it would appear that FileGetAttribute() would be an excellent way to return the status by using "B" = Blocked. Of course, there might be technical reasons that it couldn't be implemented.  But from a developer's standpoint, it would be ideal, as the status is right on the Properties panel, along with other attributes.  Maybe I can submit a request.)

Link to comment
Share on other sites

  • Developers
9 minutes ago, qwert said:

Anyone know of documentation that explains the call's syntax?

Checking the Include file the call is:

Func _WinAPI_DeleteFile($sFilePath)
    Local $aRet = DllCall('kernel32.dll', 'bool', 'DeleteFileW', 'wstr', $sFilePath)
    If @error Then Return SetError(@error, @extended, False)
    ; If Not $aRet[0] Then Return SetError(1000, 0, 0)

    Return $aRet[0]
EndFunc   ;==>_WinAPI_DeleteFile

The MS documentation for that: https://msdn.microsoft.com/en-us/library/windows/desktop/aa363915(v=vs.85).aspx

10 minutes ago, qwert said:

BTW, it would appear that FileGetAttribute() would be an excellent way to return the status by using "B" = Blocked.

Guess you mean FileGetAttrib()  which actually uses  FileGetAttribute which returns this information.
So this is not really an option as it doesn't look that information is available. Just put it in a nice UDF. ;)

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Thanks for those references.  I'll look at each to try to gain a better understanding.

In the mean time, I found what appears to be a reasonable method on a blog site: reference

... which led me to try this:

$zone = FileRead($sFile & ":Zone.Identifier")
MsgBox(0, "Attributes are:", $zone)

... which returned the text shown below.

Since it seems to work, and since my need is just to detect a Blocked file, I'm going to try to use it, for simplicity's sake.

Thanks, again.

Zone ID.PNG

 

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...