Search This Blog

Wednesday, October 17, 2018


This one will be familiar to every IT pro that has ever had to deploy something through Group Policy, when you dont have SCCM and have it only apply once, instead of at every start.

Here is a solution:

#cs ----------------------------------------------------------------------------

 AutoIt Version:
 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"
    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")

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 :)

No comments: