Creating log files for installation success and failure for installing exe file RRS feed

  • Question

  • Hi,

    I want to generate log file for installing exe but the exe does not support the generation of log files. Please help me in generating logs with powershell exit code so that powershell can generate log for the same.

    Below are my sample powershell script. Please help me in adding code for generating logs with powershell exit code.

    $LogPath = "C:\AppsLogs"

    If (!(Test-Path $LogPath)) 
       New-Item -Path $LogPath -ItemType Directory

    # Check if Application exists

    If (Get-ItemProperty -Path 'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{E936F9D8-93E1-40FC-B5AD-3B46DE0E4A46}' -Name UninstallString -ErrorAction SilentlyContinue) 

        Write-Output 'Setup.exe is already installed'|Out-File $LogLocation

    Elseif (Get-ItemProperty -Path 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\{E936F9D8-93E1-40FC-B5AD-3B46DE0E4A46}' -Name UninstallString -ErrorAction SilentlyContinue)

         Write-Output 'Setup.exe is already installed'|Out-File $LogLocation

    $Commandline="/S "
    $Process= Start-Process $InstallEXE -Argumentlist $Commandline -Wait -NoNewWindow                     



    • Moved by Bill_Stewart Friday, July 27, 2018 8:36 PM This is not "debug/fix/rewrite my script for me" forum
    Wednesday, May 23, 2018 4:48 AM

All replies

  • Hmmmm  ... what setup executable would not support creating of some logs? Did you try to check the command line arguments of your setup.exe?  setup.exe /?  mostly shows the supported command line switches and arguments. If that does not help you could run your setup executable using the cmdlet Start-process and catch the exit code like this:
    $Result = (Start-Process -FilePath "Executable including path" -ArgumentList "any arguments needed for the executable" -NoNewWindow -PassThru -Wait ).ExitCode
    If you like you can even redirect the standard output andthe standard error stream. For more information read the help please: Start-Process.

    Best regards,


    • Edited by BOfH-666 Wednesday, May 23, 2018 7:50 AM
    Wednesday, May 23, 2018 7:50 AM