Sign in to follow this
Followers
0
Close file handles on Server to replace a file with a new version
By
rudi, in AutoIt Example Scripts
-
Recently Browsing 0 members
No registered users viewing this page.
-
Similar Content
-
By TheXman
Purpose (from Microsoft's website)
The HTTP Server API enables applications to communicate over HTTP without using Microsoft Internet Information Server (IIS). Applications can register to receive HTTP requests for particular URLs, receive HTTP requests, and send HTTP responses. The HTTP Server API includes SSL support so that applications can exchange data over secure HTTP connections without IIS.
Description
There have been several times in the past that I wanted to either retrieve information from one of my PCs or execute commands on one of my PCs, whether it was from across the world or sitting on my couch. Since AutoIt is one of my favorite tools for automating just about anything on my PC, I looked for ways to make to make it happen. Setting up a full blown IIS server seemed like overkill so I looked for lighter weight solutions. I though about creating my own AutoIt UDP or TCP server but that just wasn't robust enough, Then I found Microsoft's HTTP Server API and it looked very promising. After doing a little research into the APIs, I found that it was flexible & robust enough to handle just about any of the tasks that I required now and in the future. So a while back I decided to wrap the API functionality that I needed into an AutoIt UDF file to allow me to easily create the functionality I needed at the time. It has come in very handy over the years. Of course it wasn't all wrapped up with a nice little bow like it is now. That only happened when I decided to share it with anyone else who could use it or learn from it.
The example file that I included is a very granular example of the steps required to get a lightweight HTTP Server up and listening for GET requests. The UDF is a wrapper for the Microsoft APIs. That means to do anything over and above what I show in the example, one would probably have to have at least a general knowledge of APIs or the ability to figure out which APIs/functions to use, what structures and data is needed to be passed to them, and in what order. However, the UDF gives a very solid foundation on which to build upon. Of course, if anyone has questions about the UDF or how to implement any particular functionality, I would probably help to the extent that I could or point you in the right direction so that you can figure out how to implement your own solution.
The APIs included in the UDF are the ones that I needed in the past to do what I needed to do. If any additional APIs need to be added to the UDF file, please make those suggestions in the related forum topic.
Being that this is basically an AutoIt wrapper for the Microsoft API functions, there's no need to create AutoIt-specific documentation. All of the UDF functions, structures, constants, and enumerations are named after their Microsoft API counterparts. Therefore, you can refer to Microsoft's extensive documentation of their HTTP Server API. As stated earlier, if there is one or more APIs that you find yourself needing for your particular solution, please suggest it in the related Example Scripts forum topic.
Related Links
Microsoft HTTP Server API - Start Page
Microsoft HTTP Server API - API v2 Reference
Microsoft HTTP Server API - Programming Model
-
By RestrictedUser
Hello Guys and AutoIt Scriptwriters!🎉❤️
I've created a script to notify to me if RDP main IP changed then send a message via Telegram bot to me
But some of my RDP's Main IP are @IPAddress1 or @IPAddress3 or Public IP Address...
I want to detect automatically the IP that windows client can run RDP to remotely control
This image can help you that what i say, there are three RDP with specified IP, i want to run script in these RDP's then capture those IP's changes then notify me via Telegram bot
-
By pintas
Hi!
I made a script that reads an ini file and updates the controls background color according to the ini key value.
There's another script that needs to write to that ini file, but the file is locked by this main script.
The loop keeps updating the window according to the ini contents, and that generates the flickering (and stalls the gui) but it also locks the ini file for writing.
I can't think of a logic that could solve my problem.
I'm sorry for the big script, the UI is still a bit messed up.
#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <ColorConstants.au3> #Region ### START Koda GUI section ### Form=c:\users\telmo.baia\desktop\pinshell update utility.kxf $Form1_1 = GUICreate("PinShell Update Utility", 618, 357) $MenuItem1 = GUICtrlCreateMenu("&Arquivo") $MenuItem3 = GUICtrlCreateMenuItem("Abrir arquivo de atualização", $MenuItem1) $MenuItem4 = GUICtrlCreateMenuItem("Sair", $MenuItem1) $RadioUpdAll = GUICtrlCreateRadio("Atualizar todos os micros", 16, 8, 153, 17) $RadioUpdSel = GUICtrlCreateRadio("Selecionar micros a atualizar", 16, 32, 153, 17) $iStart = GUICtrlCreateDummy() $Group1 = GUICtrlCreateGroup("OFFSET", 8, 64, 145, 265) $Check0 = GUICtrlCreateCheckbox("730", 24, 80, 39, 17) $Check1 = GUICtrlCreateCheckbox("419", 24, 96, 39, 17) $Check2 = GUICtrlCreateCheckbox("208", 24, 112, 39, 17) $Check3 = GUICtrlCreateCheckbox("702", 24, 128, 39, 17) $Check4 = GUICtrlCreateCheckbox("418", 24, 144, 39, 17) $Check5 = GUICtrlCreateCheckbox("209", 24, 160, 39, 17) $Check6 = GUICtrlCreateCheckbox("422", 24, 176, 39, 17) $Check7 = GUICtrlCreateCheckbox("218", 24, 192, 39, 17) $Check8 = GUICtrlCreateCheckbox("417", 24, 208, 39, 17) $Check9 = GUICtrlCreateCheckbox("415", 24, 224, 39, 17) $Check10 = GUICtrlCreateCheckbox("205", 24, 240, 39, 17) $Check44 = GUICtrlCreateCheckbox("999", 24, 280, 39, 17) $Label1 = GUICtrlCreateLabel("- 3R707RV-2", 64, 82, 69, 17) $Label2 = GUICtrlCreateLabel("- 4R707RV-1", 64, 98, 69, 17) $Label3 = GUICtrlCreateLabel("- 5R707", 64, 114, 45, 17) $Label4 = GUICtrlCreateLabel("- 7R707RVUV-1", 64, 130, 84, 17) $Label5 = GUICtrlCreateLabel("- 8R706UV", 64, 146, 60, 17) $Label6 = GUICtrlCreateLabel("- 9CD6UV-1", 64, 162, 64, 17) $Label7 = GUICtrlCreateLabel("- 10R701UV-1", 64, 178, 75, 17) $Label8 = GUICtrlCreateLabel("- 13CD74-6RV-1", 64, 194, 85, 17) $Label9 = GUICtrlCreateLabel("- 14R507RV-1", 64, 210, 75, 17) $Label10 = GUICtrlCreateLabel("- 15R506", 64, 226, 51, 17) $Label11 = GUICtrlCreateLabel("- 17CD102-4", 64, 242, 67, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) $Group2 = GUICtrlCreateGroup("CORTE E VINCO", 160, 64, 145, 265) $Check11 = GUICtrlCreateCheckbox("522", 176, 80, 39, 17) $Check12 = GUICtrlCreateCheckbox("521", 176, 96, 39, 17) $Check13 = GUICtrlCreateCheckbox("352", 176, 112, 39, 17) $Check14 = GUICtrlCreateCheckbox("351", 176, 128, 39, 17) $Check15 = GUICtrlCreateCheckbox("350", 176, 144, 39, 17) $Check16 = GUICtrlCreateCheckbox("220", 176, 160, 39, 17) $Check17 = GUICtrlCreateCheckbox("416", 176, 176, 39, 17) $Check18 = GUICtrlCreateCheckbox("703", 176, 192, 39, 17) $Check19 = GUICtrlCreateCheckbox("214", 176, 208, 39, 17) $Check20 = GUICtrlCreateCheckbox("212", 176, 224, 39, 17) $Check21 = GUICtrlCreateCheckbox("213", 176, 240, 39, 17) $Check22 = GUICtrlCreateCheckbox("219", 176, 256, 39, 17) $Check23 = GUICtrlCreateCheckbox("731", 176, 272, 39, 17) $Check24 = GUICtrlCreateCheckbox("295", 176, 288, 39, 17) $Label16 = GUICtrlCreateLabel("- VISIO-2", 216, 82, 50, 17) $Label17 = GUICtrlCreateLabel("- VISIO-1", 216, 98, 50, 17) $Label18 = GUICtrlCreateLabel("- NOVAC-3", 216, 114, 59, 17) $Label19 = GUICtrlCreateLabel("- NOVAC-1", 216, 130, 59, 17) $Label20 = GUICtrlCreateLabel("- NOVAC-2", 216, 146, 59, 17) $Label21 = GUICtrlCreateLabel("- SPERIA-1", 216, 162, 61, 17) $Label22 = GUICtrlCreateLabel("- SPERIA-2", 216, 178, 61, 17) $Label23 = GUICtrlCreateLabel("- SP-102-5", 216, 194, 57, 17) $Label24 = GUICtrlCreateLabel("- SP-102-1", 216, 210, 57, 17) $Label25 = GUICtrlCreateLabel("- SP-102-4", 216, 226, 57, 17) $Label26 = GUICtrlCreateLabel("- SP-102-2", 216, 242, 57, 17) $Label27 = GUICtrlCreateLabel("- SP-102-3", 216, 258, 57, 17) $Label28 = GUICtrlCreateLabel("- SP-102-6", 216, 274, 57, 17) $Label29 = GUICtrlCreateLabel("- EASY", 216, 290, 41, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) $Group3 = GUICtrlCreateGroup("COLAGEM", 312, 64, 145, 265) $Check25 = GUICtrlCreateCheckbox("261", 328, 80, 39, 17) $Check26 = GUICtrlCreateCheckbox("704", 328, 96, 39, 17) $Check27 = GUICtrlCreateCheckbox("264", 328, 112, 39, 17) $Check28 = GUICtrlCreateCheckbox("263", 328, 128, 39, 17) $Check29 = GUICtrlCreateCheckbox("262", 328, 144, 39, 17) $Check30 = GUICtrlCreateCheckbox("705", 328, 160, 39, 17) $Check31 = GUICtrlCreateCheckbox("421", 328, 176, 39, 17) $Check32 = GUICtrlCreateCheckbox("420", 328, 192, 39, 17) $Check33 = GUICtrlCreateCheckbox("258", 328, 208, 39, 17) $Check34 = GUICtrlCreateCheckbox("253", 328, 224, 39, 17) $Check35 = GUICtrlCreateCheckbox("255", 328, 240, 39, 17) $Check36 = GUICtrlCreateCheckbox("251", 328, 256, 39, 17) $Check37 = GUICtrlCreateCheckbox("252", 328, 272, 39, 17) $Label31 = GUICtrlCreateLabel("- EXPERT-3", 368, 82, 65, 17) $Label32 = GUICtrlCreateLabel("- EXPERT-5", 368, 98, 65, 17) $Label33 = GUICtrlCreateLabel("- EXPERT-1", 368, 114, 65, 17) $Label34 = GUICtrlCreateLabel("- EXPERT-2", 368, 130, 65, 17) $Label35 = GUICtrlCreateLabel("- EXPERT-4", 368, 146, 65, 17) $Label36 = GUICtrlCreateLabel("- EXPERT-6", 368, 162, 65, 17) $Label37 = GUICtrlCreateLabel("- AM-105-1", 368, 178, 59, 17) $Label38 = GUICtrlCreateLabel("- AM-105-2", 368, 194, 59, 17) $Label39 = GUICtrlCreateLabel("- MD-100-1", 368, 210, 60, 17) $Label40 = GUICtrlCreateLabel("- MD-68-1", 368, 226, 54, 17) $Label41 = GUICtrlCreateLabel("- MD-45-1", 368, 242, 54, 17) $Label47 = GUICtrlCreateLabel("- RICALL", 368, 258, 50, 17) $Label49 = GUICtrlCreateLabel("- BABY", 368, 274, 41, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) $Group4 = GUICtrlCreateGroup("HOT-STAMP", 464, 64, 145, 89) $Check38 = GUICtrlCreateCheckbox("230", 480, 80, 39, 17) $Check39 = GUICtrlCreateCheckbox("424", 480, 96, 39, 17) $Check40 = GUICtrlCreateCheckbox("425", 480, 112, 39, 17) $Label42 = GUICtrlCreateLabel("- STEUER", 520, 82, 57, 17) $Label43 = GUICtrlCreateLabel("- FURNAX-HS", 520, 98, 75, 17) $Label44 = GUICtrlCreateLabel("- FURNAX-HS-2", 520, 114, 84, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) $Group5 = GUICtrlCreateGroup("VERNIZ", 464, 152, 145, 89) $Check41 = GUICtrlCreateCheckbox("291", 480, 168, 39, 17) $Check42 = GUICtrlCreateCheckbox("290", 480, 184, 39, 17) $Label45 = GUICtrlCreateLabel("- VERCAL-1", 520, 170, 64, 17) $Label46 = GUICtrlCreateLabel("- VERCAL-2", 520, 186, 64, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) $Group6 = GUICtrlCreateGroup("MANUTENÇÃO", 464, 240, 145, 89) $Check43 = GUICtrlCreateCheckbox("MICRO0177", 480, 256, 80, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) $iEnd = GUICtrlCreateDummy() $ButtonUpdate = GUICtrlCreateButton("Atualizar", 464, 10, 147, 35) $ButtonCleanSel = GUICtrlCreateButton("Limpar seleção", 180, 27, 80, 25) GUICtrlSetState($ButtonCleanSel, $GUI_DISABLE); ###################################################### HABILITAR BOTÃO DE LIMPAR SELEÇÃO SÓ QUANDO ATUALIZAR TODOS NÃO ESTIVER SELECIONADO E NENHUMA SELEÇÃO FEITA GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### $Shell = "PinShell" $PUUFile = "PUU.dat" $PUUPath = "M:\vm2\" & $Shell & "\" & $Shell & "\" $PUU = $PUUPath & $PUUFile ;~ local CheckStatus() CheckStatus() While 1 CheckStatus() $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $MenuItem4 Exit Case $MenuItem3 Run ( "notepad.exe " & $PUUFile, $PUUPath) Case $RadioUpdAll For $i = $iStart To $iEnd GUICtrlSetState($i, $GUI_DISABLE) Next ;~ IniWrite($PUU, "MTU Selection", "ALL", "1") Case $RadioUpdSel For $i = $iStart To $iEnd GUICtrlSetState($i, $GUI_ENABLE) Next Case $ButtonUpdate If GUICtrlRead($RadioUpdAll) = 1 Then IniWrite($PUU, "MTU Selection", "ALL", "1") If IniRead($PUU, "MTU Selection", "ALL", "") = 1 Then MsgBox(64, "Informação", "Definida atualização geral automatica.") EndIf ElseIf GUICtrlRead($RadioUpdSel) = 1 Then For $1 = 0 To 44 ; ######################################### ALTERAR NÚMERO DE ACORDO COM AS CHECKBOXES (MÁQUINAS) EXISTENTES If GUICtrlRead(Eval('Check' & $1)) = 1 Then IniWrite($PUU, "MTU Selection", GUICtrlRead(Eval('Check' & $1), 1), "1") If GUICtrlRead(Eval('Check' & $1)) <> 1 Then IniWrite($PUU, "MTU Selection", GUICtrlRead(Eval('Check' & $1), 1), "0") Next IniWrite($PUU, "MTU Selection", "ALL", "0") If IniRead($PUU, "MTU Selection", "ALL", "") = 0 Then MsgBox(64, "Informação", "Definidos micros para atualizar automaticamente.") EndIf EndIf EndSwitch WEnd Func CheckStatus() For $1 = 0 To 44 ; ######################################### ALTERAR NÚMERO DE ACORDO COM AS CHECKBOXES (MÁQUINAS) EXISTENTES If IniRead($PUU, "MTU Selection", GUICtrlRead(Eval('Check' & $1), 1), "") = 1 Then GUICtrlSetState(Eval('Check' & $1), $GUI_CHECKED) Next For $1 = 0 To 44 ; ######################################### ALTERAR NÚMERO DE ACORDO COM AS CHECKBOXES (MÁQUINAS) EXISTENTES If IniRead($PUU, "MTU Selection", GUICtrlRead(Eval('Check' & $1), 1), "") = "A" Then DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", Eval('Check' & $1), "wstr", 0, "wstr", 0) GUICtrlSetBkColor(Eval('Check' & $1), $COLOR_GREEN) EndIf Next For $1 = 0 To 44 ; ######################################### ALTERAR NÚMERO DE ACORDO COM AS CHECKBOXES (MÁQUINAS) EXISTENTES If IniRead($PUU, "MTU Selection", GUICtrlRead(Eval('Check' & $1), 1), "") = "N" Then DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", Eval('Check' & $1), "wstr", 0, "wstr", 0) GUICtrlSetBkColor(Eval('Check' & $1), $COLOR_RED) EndIf Next If IniRead($PUU, "MTU Selection", "ALL", "") = 1 Then GUICtrlSetState($RadioUpdAll, $GUI_CHECKED) For $i = $iStart To $iEnd GUICtrlSetState($i, $GUI_DISABLE) Next Else GUICtrlSetState($RadioUpdSel, $GUI_CHECKED) For $i = $iStart To $iEnd GUICtrlSetState($i, $GUI_ENABLE) Next EndIf EndFunc
-
By rudi
Hello,
Either drag drop the opened file on the server and the temp file, Aut2Exe could not copy to the destination file, as that one is opened, to the edits of this GUI, or take the Aut2Exe error message line to your clipboard, the line will be split automatically.
This script does not check
For the required rights to the destination folder (to close open file handles) for correct input Use either clipboard (Aut2Exe message), drag & drop, or copy the full paths of source and destination file *IN ONE* (don't type, if you want to do so, modify the script, for me it's fine this way ;-)
Example Error Message:
!>11:19:15 Problem copying file from: C:\Users\UserName\AppData\Local\AutoIt v3\Aut2exe\~AU98E6.tmp.exe To :z:\MyAutoitExeForTheUsers.exe
#include <GUIConstantsEx.au3> #include <NetShare.au3> #include <WindowsConstants.au3> #include <Array.au3> #include <EditConstants.au3> ; Enumerate open files on the server $DragDropOpenFile = "<drag drop the opened file on a server share here>" $DragDropNewFile = "<drag drop the file supposed to replace the above one here>" $NewFile = "" $Gui_h = 250 $Gui_w = 800 $vDist = 7 ; GUICreate($GuiTitle, $w, $h, @DesktopWidth - $w - 100, @DesktopHeight - $h - 60, -1, $WS_EX_ACCEPTFILES) ; generally enable drag-drop for files into other GUI controls $myGui = GUICreate("Tool to forcibly close & replace open files on server shares", $Gui_w, $Gui_h, 100, 100, -1, $WS_EX_ACCEPTFILES) $InputFileToClose = GUICtrlCreateInput($DragDropOpenFile, 20, $vDist, $Gui_w - 40, 20) GUICtrlSetState(-1, $GUI_DROPACCEPTED) ; allow drag-droping files for this control, $InputFile Opt("Guicoordmode", 2) $InputFileNew = GUICtrlCreateInput($DragDropNewFile, -1, $vDist) GUICtrlSetState(-1, $GUI_DROPACCEPTED) ; allow drag-droping files for this control, $InputFile GUICtrlSetState(-1, $GUI_DISABLE) $lServer = GUICtrlCreateLabel("<server>", -1, $vDist) $lShare = GUICtrlCreateLabel("<share-mapping>", -1, $vDist) $lPath = GUICtrlCreateLabel("<sub-path>", -1, $vDist) $lFile = GUICtrlCreateLabel("<file>", -1, $vDist) $doit = GUICtrlCreateButton("Search and close for open file handles", -1, $vDist) GUICtrlSetState(-1, $GUI_DISABLE) $exit = GUICtrlCreateButton("Cancel", -1, $vDist) GUISetState() $FN = False $FNnew = "" $FNmatch = False $ToolTitle = "" $ToolTxt = "" $RegExA2E = "(?i)^(?:.*?Problem copying file from: )(.*?)(?: To :)(.*$)" ; $1 = compiled local TEMP file, $2 = not replacable destination file ; Examle Replacement failed output: !>11:19:15 Problem copying file from: C:\Users\USERNAME\AppData\Local\AutoIt v3\Aut2exe\~AU98E6.tmp.exe To :z:\MyAutoitExeForTheUsers.exe While 1 $Clip = ClipGet() If StringRegExp($Clip, $RegExA2E) Then $Src = StringRegExpReplace($Clip, $RegExA2E, "$2") GUICtrlSetData($InputFileToClose, $Src) $Dst = StringRegExpReplace($Clip, $RegExA2E, "$1") GUICtrlSetData($InputFileNew, $Dst) EndIf $input = GUICtrlRead($InputFileToClose) If $input <> $DragDropOpenFile Then ; da wurde was reingezogen $DragDropOpenFile = $input If StringLeft($input, 2) = "\\" Then $Type = "UNC" $ServerShareUNC = StringLeft($input, StringInStr($input, "\", 0, 4) - 1) $fRelPathFN = StringReplace($input, $ServerShareUNC, "") $fPath = StringLeft($fRelPathFN, StringInStr($fRelPathFN, "\", 0, -1)) $FN = StringTrimLeft($fRelPathFN, StringInStr($fRelPathFN, "\", 0, -1)) ElseIf StringMid($input, 2, 1) = ":" Then ; Pfad mit Laufwerksbuchstabe, evtl. Netzwerk Mapping (erforderlich) $drive = StringLeft($input, 2) $Type = DriveGetType($drive) If $Type = "Network" Then $ServerShareUNC = DriveMapGet($drive) $foo = StringReplace($input, $drive, $ServerShareUNC) ; Laufwerkspfad in UNC Pfad umwandeln $fRelPathFN = StringReplace($foo, $ServerShareUNC, "") $fPath = StringLeft($fRelPathFN, StringInStr($fRelPathFN, "\", 0, -1)) $FN = StringTrimLeft($fRelPathFN, StringInStr($fRelPathFN, "\", 0, -1)) Else MsgBox(48, @ScriptLineNumber, "This script can *ONLY* close remotely handles for files open on server shares!" & @CRLF & _ $input & @CRLF & _ $drive & " = " & $Type) ContinueLoop 2 EndIf EndIf $Server = StringLeft($ServerShareUNC, StringInStr($ServerShareUNC, "\", 0, 3) - 1) $Share = StringTrimLeft($ServerShareUNC, StringInStr($ServerShareUNC, "\", 0, 3) - 1) GUICtrlSetData($lServer,"Server = '" & $Server& "'") GUICtrlSetData($lShare, "Mapping = '" & $Share & "'") GUICtrlSetData($lPath, "SubPath = '" &$fPath & "'") GUICtrlSetData($lFile, "FileName= '" & $FN &"'") GUICtrlSetState($doit, $GUI_ENABLE) GUICtrlSetState($InputFileNew, $GUI_ENABLE) EndIf If $NewFile <> GUICtrlRead($InputFileNew) Then $NewFile = GUICtrlRead($InputFileNew) If $NewFile <> $DragDropNewFile Then If StringInStr($NewFile, $DragDropNewFile) Then $NewFile = StringReplace($NewFile, $DragDropNewFile, "") GUICtrlSetData($InputFileNew, $NewFile) EndIf $FNnew = StringTrimLeft($NewFile, StringInStr($NewFile, "\", 0, -1)) If $FN = $FNnew Then If $FNmatch = False Then $FNmatch = True GUICtrlSetData($doit, "Search for & Close open file handles, then replace file") EndIf Else If $FNmatch Then $FNmatch = False GUICtrlSetData($doit, "Search for & Close open file handles, then replace file") GUICtrlSetData($InputFileNew, $DragDropNewFile) EndIf EndIf EndIf EndIf Switch GUIGetMsg() Case $exit, $GUI_EVENT_CLOSE GUIDelete($myGui) Exit Case $doit AbArbeiten($Server, $Share, $fPath, $FN) EndSwitch WEnd Func AbArbeiten($_Srv, $_Shr, $_fPth, $_fNme) Local $iID = 0 Local $iRights = 1 Local $iLckCount = 2 Local $iFPFN = 3 Local $iUser = 4 ConsoleWrite($_fPth & $_fNme & @CRLF) Local $aFile = _Net_Share_FileEnum($_Srv) If IsArray($aFile) Then ; _ArrayDisplay($aFile) Local $x $ToolTxt = "Open File Handles:" $ToolTitle = "Handles to be checked total: " & $aFile[0][0] UpdateToolTip() AdlibRegister(UpdateToolTip, 1000) For $x = $aFile[0][0] To 1 Step -1 $ToolTitle = $x & " handles remaining for checking..." If Not StringInStr($aFile[$x][$iFPFN], $_fPth & $_fNme) Then ; ConsoleWrite("Nix Enthalten in: " & $aFile[$x][$iFPFN] & @CRLF) _ArrayDelete($aFile, $x) Else $ToolTxt &= @CRLF & $aFile[$x][$iFPFN] & ", User = " & $aFile[$x][$iUser] ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $ToolTxt = ' & $ToolTxt & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console EndIf Next $aFile[0][0] = UBound($aFile) - 1 _ArraySort($aFile, 0, 1, 0, $iUser) ; _ArrayDisplay($aFile, $aFile[0][0] & " FileLocks found.") If $aFile[0][0] = 0 Then $ToolTitle = "Done, no open file handles were found" $ToolTxt &= @CRLF & ", no handles to be closed for this file!" Sleep(2000) $ToolTxt = "" ReplaceFile() Else $ToolTitle = $aFile[0][0] & " open file handles were found..." $CloseErr = 0 For $x = 1 To $aFile[0][0] If _Net_Share_FileClose($Server, $aFile[$x][$iID]) Then $ToolTxt &= @CRLF & @TAB & "Handle closed: " & $aFile[$x][$iID] Else $ToolTxt &= @CRLF & "ERROR: Handle Close Failed! --> " & $aFile[$x][$iFPFN] & ", User = " & $aFile[$x][$iUser] $CloseErr += 1 EndIf Next ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $CloseErr = ' & $CloseErr & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console If $CloseErr = 0 Then $ToolTitle = "All found open file handles could be closed." ReplaceFile() Else $ToolTitle = $CloseErr & " Handles could *NOT* be closed!" Sleep(2000) EndIf Sleep(1000) $ToolTxt = "" $ToolTitle = "" EndIf Else MsgBox(0, "not an array", $aFile & @CRLF & @error & @CRLF & @extended & @CRLF & _ "Unable to retrieve the array of open file handles for " & $Share) EndIf EndFunc ;==>AbArbeiten Func UpdateToolTip() ToolTip($ToolTxt, MouseGetPos(0) + 20, MouseGetPos(1) + 20, $ToolTitle) ; ConsoleWrite( $ToolTxt & @CRLF & $ToolTitle & @CRLF & "-------------------" & @CRLF) EndFunc ;==>UpdateToolTip Func ReplaceFile() If FileExists($NewFile) Then If FileCopy($NewFile, $input, 1 + 8) Then $ToolTitle = "File successfully replaced." $ToolTxt = "Done" Else $ToolTitle = "File could *NOT* be replaced." $ToolTxt = "Possibly another open file handle spawned while this script was running." & @CRLF & _ "Simply start over again, please." MsgBox(48, $ToolTitle, $ToolTxt) EndIf EndIf EndFunc ;==>ReplaceFile
-
By Spartan117
Hi everyone,
I wonder if there is a cloud service that can offer a physical server so that AutoIT can turn as it is in a physical machine.
Thank you
-