i2i8 Posted February 6, 2014 Posted February 6, 2014 (edited) This is my script, it seems not perfect, can you help me write a more perfect example of it? #include <File.au3> Local $setFiles[13] $setFiles[0] = @ScriptDir & "\idsdk.dll" $setFiles[1] = @ScriptDir & "\sdk.dll" $setFiles[2] = @ScriptDir & "\ProcSafe.exe" $setFiles[3] = @ScriptDir & "\Safe.dll" $setFiles[4] = @ScriptDir & "\BHOEx.dll" $setFiles[5] = @ScriptDir & "\CServer.dll" $setFiles[6] = @ScriptDir & "\vDiskBus.inf" $setFiles[7] = @ScriptDir & "\vDiskBus.sys" $setFiles[8] = @ScriptDir & "\nti.exe" $setFiles[9] = @ScriptDir & "\GdiPlus.dll" $setFiles[10] = @ScriptDir & "\data\ClientBrand.ini" $setFiles[11] = @ScriptDir & "\data\GameSearchCfg.ini" $setFiles[12] = @ScriptDir & "\processSafe\ProcessSafe.ini" For $i = 0 To UBound($setFiles) -1 If FileExists($setFiles[$i]) Then FileDelete($setFiles[$i]) ElseIf Not FileExists($setFiles[$i]) Then _FileCreate($setFiles[$i]) Sleep(200) FileSetAttrib($setFiles[$i],"+RSH") EndIf Next Local $SetACL_Set = "SetACL -on ",$copy_permissions = ' -ot file -actn setprot -op "dacl:p_c;sacl:p_c"',$remove_permissions = ' -ot file -actn clear -clr "dacl,sacl"',$iRead_ex = ' -ot file -actn ace -ace "n:Everyone;p:read_ex"' For $i = 0 To UBound($setFiles) -1 If FileExists($setFiles[$i]) Then RunWait(@ComSpec & " /c " & $SetACL_Set & $setFiles[$i] & $copy_permissions,"",@SW_HIDE) RunWait(@ComSpec & " /c " & $SetACL_Set & $setFiles[$i] & $remove_permissions,"",@SW_HIDE) RunWait(@ComSpec & " /c " & $SetACL_Set & $setFiles[$i] & $iRead_ex,"",@SW_HIDE) EndIf Next MsgBox(0,"Waiting......","Waiting......",3) Run this script there is a problem, the first run, does not create an empty file with the same name, run it again, it can create $ setFiles function definitions for all files.Why? Edited February 6, 2014 by i2i8
FireFox Posted February 6, 2014 Posted February 6, 2014 Hi, In your first For loop : If FileExists Then DeleteFile << The file exists and is deleted ElseIf Not FileExists Then FileCreate << The file does NOT exist and is created EndIf The code cannot pass from an If to another one, so either the file exists or it does not. expandcollapse popup#include <File.au3> #include <Constants.au3> Local $setFiles[13] = [ _ "idsdk.dll", _ "sdk.dll", _ "ProcSafe.exe", _ "Safe.dll", _ "BHOEx.dll", _ "CServer.dll", _ "vDiskBus.inf", _ "vDiskBus.sys", _ "nti.exe", _ "GdiPlus.dll", _ "data\ClientBrand.ini", _ "data\GameSearchCfg.ini", _ "processSafe\ProcessSafe.ini"] For $i = 0 To UBound($setFiles) - 1 If FileExists(@ScriptDir & "\" & $setFiles[$i]) Then FileDelete(@ScriptDir & "\" & $setFiles[$i]) EndIf ;the file is necessarily deleted _FileCreate(@ScriptDir & "\" & $setFiles[$i]) ;Sleep(200) ;Why?? FileSetAttrib(@ScriptDir & "\" & $setFiles[$i], "+RSH") Next Local $SetACL_Set = "SetACL -on" Local $copy_permissions = '-ot file -actn setprot -op "dacl:p_c;sacl:p_c"' Local $remove_permissions = '-ot file -actn clear -clr "dacl,sacl"' Local $iRead_ex = '-ot file -actn ace -ace "n:Everyone;p:read_ex"' For $i = 0 To UBound($setFiles) - 1 If FileExists(@ScriptDir & "\" & $setFiles[$i]) Then ;this may be useless as the file is created before RunWait(@ComSpec & " /c " & $SetACL_Set & " " & @ScriptDir & "\" & $setFiles[$i] & " " & $copy_permissions, "", @SW_HIDE) RunWait(@ComSpec & " /c " & $SetACL_Set & " " & @ScriptDir & "\" & $setFiles[$i] & " " & $remove_permissions, "", @SW_HIDE) RunWait(@ComSpec & " /c " & $SetACL_Set & " " & @ScriptDir & "\" & $setFiles[$i] & " " & $iRead_ex, "", @SW_HIDE) EndIf Next MsgBox($MB_SYSTEMMODAL, "Waiting......", "Waiting......", 3) Br, FireFox. i2i8 1
i2i8 Posted February 6, 2014 Author Posted February 6, 2014 Thank you very much FireFox, I will now try your script.
water Posted February 6, 2014 Posted February 6, 2014 i2i8, you have already a thread for this issue. Why don't you stick with that? title="View Topic">Function definition files can be deleted, but can not create the same file? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now