Skip to main content

Simple application install template (EXE) - WINDOWS

  • March 28, 2023
  • 1 reply
  • 515 views

schweeeeet
Forum|alt.badge.img

I needed to make creating software install worklets accessible to non-script savvy people on my team, so I came up with these.


Real simple… change the variables as instructed in the script notes, copy/paste into a worklet and that’s it.  This should be quite accessible for even the most n00bish PowerShell users.

 

##############################################################################
### ~~~        SWEET'S EXE INSTALL SCRIPT TEMPLATE FOR AUTOMOX!        ~~~ ###
##############################################################################
### --NOTES-- ### 
##############################################################################   
###  - Set the name of the software                                        ###
###  - Set the path to the executable file                                 ###
###  - Set the name of the log file                                        ###
###  - Copy/Paste into Worklet!!                                           ###
##############################################################################


#################################################################
###   ><><><><><><   START EVALUATION CODE!!!  ><><><><><><   ###
#################################################################

# VARIABLES LIST

$swname = "INSERT-SW-NAME-HERE" # ex. "Java 8.341 (32-bit)"

$swpath = "INSERT-SW-PATH-HERE" # ex. "C:\Program Files\Java"

$logname = "INSERT-LOG-NAME-HERE" # ex. "OfficeUpgrade.log"

# Create C:\Temp if it doesn't yet exist

New-Item -Path 'C:\Temp' -ItemType Directory -Force -ErrorAction SilentlyContinue

# Start logging

Start-Transcript -Verbose -Path "C:\Temp\$logname"

$output = Test-Path $swpath

if ($output){
  Write-Output "$swname is already installed."
 } else { 
  Write-Output "$swname not present - installer will begin shortly."
}

Stop-Transcript

if ($output){
  Exit 0
 } else { 
  Exit 1  
}

#################################################################
###   ><><><><><><   END EVALUATION CODE!!!!!  ><><><><><><   ###
#################################################################

# COPY ABOVE THIS LINE INTO EVALUATION PANE

#---------------------------------------------------------------#

# COPY BELOW THIS LINE INTO REMEDIATION PANE

#################################################################
###   ><><><><><><   START REMEDIATION CODE!!  ><><><><><><   ###
#################################################################

# Set Variables!

$swname = "INSERT-SW-NAME-HERE" # ex. "Java 8.341 (32-bit)"

$swfilename = "INSERT-SW-FILENAME-HERE" # ex. "setup.exe"

$logname = "INSERT-LOG-NAME-HERE" # ex. "OfficeUpgrade.log"

$arguments = "INSERT-ARGS-HERE" # ex. '/i "MicrosoftEdgeEnterpriseX64.msi" /q' TOP TIP! - You may need to use single quotes at the start/end!!

# Starts logging and appends the existing log file created by the Evaluation code

Start-Transcript -Verbose -Path "C:\Temp\$logname" -Append

Write-Output "Copying install files..."

Copy-Item $swfilename -Destination "C:\Temp" -Verbose

Write-Output "Install files copied to C:\Temp."

Write-Output "Executing install command..."

# Executing installer - DO NOT make your life harder, eliminate spaces in filenames!
    try
    {
        Start-Process "C:\Temp\$swfilename" -ArgumentList $arguments -Wait

    }
    catch
    {
        Write-Output "Install of $swname Failed"
        Exit -1
    }
    Write-Output "$swname install command executed."

    Remove-Item -Path "C:\Temp\$swfilename"

Stop-Transcript

#################################################################
###   ><><><><><><   END REMEDIATION CODE!!!!  ><><><><><><   ###
#################################################################

 

1 reply

  • 1 reply
  • March 28, 2023

Thank you.


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings