Here is a solution:
#cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.14.2 Author: Alex Belenkiy © 2018 Created: 09/21/2018 Last Update: 09/24/2018 Script Function: Run an install or a program only once To execute run as follows: RunOnce.exe "\\server\share\folder\file.exe" "/i /qn" "c:\program Files\RunOnce\test.txt" or RunOnce.exe "\\server\share\folder\file.exe" - "c:\program Files\RunOnce\test.txt" #ce ---------------------------------------------------------------------------- if $CmdLine[0] <> 3 then Exit $CommandFile = $CmdLine[1] $Switches = $CmdLine[2] if $Switches = "-" then $Switches = "" $FlagFile = $CmdLine[3] if FileExists ($FlagFile) then Exit $a = RunWait(@ComSpec & " /c " & $CommandFile & " " & $Switches, @SystemDir, @SW_HIDE) if @error then Exit $File = FileOpen ($FlagFile, 10) if @error then Exit FileWriteLine($File,"RunOnce Executed") FileClose($File)
If the file named by the third variable exists when the runonce.exe executes, the program will just exit. If the file does not exist, the first variable will be executed along with the switches passed in the second variable. Use a - for the second variable to specify no switches. Once the execution has completed, the file in the third variable will be created.
Enjoy and modify as needed :)