Jump to content

Recommended Posts

Posted

Now I try to write the script to test the file.

When I open the Microsoft Word use the function ShellExecute() although the file is opened, Word just shows the error message that file has been destroyed.

But I try to open the file by myself, the file was being opened successfully, without any error.

have any solution for this problem?

Thanks!

2018-07-23 (1).png

Posted
7 minutes ago, Danp2 said:

Show your code if you want some meaningful feedback. My guess would be that Word can't find the document due to you not supplying the correct path.

OK, here is my code.

The file was open successfully a few hours ago but suddenly can't open it. I think if my path was incorrect may even can't open the file.

test.au3

Posted
5 minutes ago, starlitsky said:

OK, here is my code.

The file was open successfully a few hours ago but suddenly can't open it. I think if my path was incorrect may even can't open the file.

test.au3

How can I append my code rather than drag files?

Posted
Just now, FrancescoDiMuro said:

@starlitsky
Use the Code tag ( <> ) here above :)

<>

Dim $FIlter = "D:\TestFloder"

Func ScanFolder(const $Path)
   Local $search = FileFindFirstFile($Path & "\*.*")
   Local $FullPath

   If $search = -1 Then Return
   Local $first = 1
   If $first = 1 Then
      FileWriteLine($openFile, "=====================")
   EndIf
   While 1
      Local $file = FileFindNextFile($search)
      If @error Then ExitLoop ;break
      Local $test
      $FullPath = $Path & "\" & $file

      If Not StringInStr(FileGetAttrib($FullPath), "D") Then
         FileWrite($openFile, $file)
         Local $testOpen = FileOpen($FullPath, $FO_READ) ;just read the file
         If $testOpen = -1 Then
            FileWriteLine($openFile, " -> Error!")
         Else
            $PID = ShellExecute($FullPath)
            If $PID = -1 Then
               $ErrorCount += 1
               FileWriteLine($openFile, " -> Error! : with return" & $PID)
            EndIf
            Else ;...another things I try, such as print, save the file
         EndIf
         FileClose($FullPath)
         FileWrite($openFile, $file & " close complete!" & @CRLF)
      Else
         FileWriteLine($openFile, $file)
      EndIf

      If IsFolder($FullPath) = 1 Then
         ScanFolder($FullPath); if still have folder then sreach it recursively
         $FolderCount += 1
      Else
         $FileCount += 1
      EndIf
   WEnd
   FileWrite($openFile, @CRLF)
   FileWrite($openFile, "=====================" & @CRLF)
   FileClose($search)
EndFunc

Posted
1 minute ago, FrancescoDiMuro said:

This one:

image.thumb.png.3aa2e36c440e88abe48fc6866b3944ed.png

Dim $FIlter = "D:\TestFloder"

Func ScanFolder(const $Path)
   Local $search = FileFindFirstFile($Path & "\*.*")
   Local $FullPath

   If $search = -1 Then Return
   Local $first = 1
   If $first = 1 Then
      FileWriteLine($openFile, "=====================")
   EndIf
   While 1
      Local $file = FileFindNextFile($search)
      If @error Then ExitLoop ;break
      Local $test
      $FullPath = $Path & "\" & $file

      If Not StringInStr(FileGetAttrib($FullPath), "D") Then
         FileWrite($openFile, $file)
         Local $testOpen = FileOpen($FullPath, $FO_READ) ;just read the file
         If $testOpen = -1 Then
            FileWriteLine($openFile, " -> Error!")
         Else
            $PID = ShellExecute($FullPath)
            If $PID = -1 Then
               $ErrorCount += 1
               FileWriteLine($openFile, " -> Error! : with return" & $PID)
            EndIf
            Else ;...another things I try, such as print, save the file
         EndIf
         FileClose($FullPath)
         FileWrite($openFile, $file & " close complete!" & @CRLF)
      Else
         FileWriteLine($openFile, $file)
      EndIf

      If IsFolder($FullPath) = 1 Then
         ScanFolder($FullPath); if still have folder then sreach it recursively
         $FolderCount += 1
      Else
         $FileCount += 1
      EndIf
   WEnd
   FileWrite($openFile, @CRLF)
   FileWrite($openFile, "=====================" & @CRLF)
   FileClose($search)
EndFunc

OK, I see. 😂

Posted
6 minutes ago, mikell said:

You might try _FileListToArrayRec  :)

I use shellExecute() because I need the GUI to control some situation, I just check If the encrypted file without the permissions can modify(such as paste, copy, print, capture ...etc.) the file.

Posted
3 minutes ago, starlitsky said:

I use shellExecute() because I need the GUI to control some situation, I just check If the encrypted file without the permissions can modify(such as paste, copy, print, capture ...etc.) the file.

I just use the same code to run the test, but it works in morning, but now (p.m. 9: 05) can't work, and I don't why.

Posted

I finally find my problem, just because I use #RequireAdmin to open the file.

 When the permission been changed, the file will skip my check. Now it works normally! Thanks, everyone!🙂

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
  • Recently Browsing   0 members

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