diff --git a/InstallerProjects/Installer/Installer.wixproj b/InstallerProjects/Installer/Installer.wixproj
index 9bcbe6470..9d309961f 100644
--- a/InstallerProjects/Installer/Installer.wixproj
+++ b/InstallerProjects/Installer/Installer.wixproj
@@ -110,21 +110,6 @@
HarvestPath=$(SolutionDir)mRemoteV1\bin\Release Portable;HelpFilesHarvestPath=$(SolutionDir)mRemoteV1\Resources\Help
-
- :: When passing paths to powershell scripts, check if the path ends with a backslash "\"
-:: If it does, then the backslash may be interpreted as an escape character. Add another backslash to cancel the first one.
-
-powershell -noprofile -command "sleep 2"
-set /p buildenv=<buildenv.tmp
-set solutionDir=$(SolutionDir)\
-set targetDir=%25cd%25
-set psScriptsDir=$(SolutionDir)Tools
-set certPath=$(CertPath)
-set certPassword=$(CertPassword)
-
-:: Call the post build powershell script
-powershell.exe -ExecutionPolicy Bypass -File "%25psScriptsDir%25\postbuild_installer.ps1" -SolutionDir "%25solutionDir%25" -TargetDir "%25targetDir%25" -TargetFileName "mRemoteNG.exe" -ConfigurationName "%25buildenv%25" -CertificatePath "%25certPath%25" -CertificatePassword "%25certPassword%25"
-
REM Clean the TargetDir
rmdir /S /Q "$(TargetDir)"
@@ -137,4 +122,17 @@ REM Harvest bin directory of the mRemoteV1 project
REM Convert the license file "COPYING.TXT" to "License.rtf" to be shown in the installer GUI
"$(ProjectDir)Resources\Pandoc\pandoc.exe" -s -t rtf -o "$(ProjectDir)\Resources\License.rtf" "$(SolutionDir)COPYING.TXT"
+
+ :: When passing paths to powershell scripts, check if the path ends with a backslash "\"
+:: If it does, then the backslash may be interpreted as an escape character. Add another backslash to cancel the first one.
+
+powershell -noprofile -command "sleep 2"
+
+set /p buildenv=<buildenv.tmp
+
+IF "%25APPVEYOR_BUILD_FOLDER"=="" (set cert_pwd=$(CertPassword))
+
+:: Call the post build powershell script
+powershell.exe -ExecutionPolicy Bypass -File "$(SolutionDir)Tools\postbuild_mremotev1.ps1" -SolutionDir "$(SolutionDir)\" -TargetDir "%25cd%25" -TargetFileName "mRemoteNG.exe" -ConfigurationName "%25buildenv%25" -CertificatePath "$(CertPath)" -CertificatePassword "%25cert_pwd%25" -ExcludeFromSigning "PuTTYNG.exe"
+
\ No newline at end of file
diff --git a/mRemoteV1/mRemoteV1.csproj b/mRemoteV1/mRemoteV1.csproj
index b34cb0ea7..6a418c0ba 100644
--- a/mRemoteV1/mRemoteV1.csproj
+++ b/mRemoteV1/mRemoteV1.csproj
@@ -1770,18 +1770,14 @@
:: When passing paths to powershell scripts, check if the path ends with a backslash "\"
:: If it does, then the backslash may be interpreted as an escape character. Add another backslash to cancel the first one.
-@echo off
powershell -noprofile -command "sleep 2"
+
set /p buildenv=<buildenv.tmp
-set solutionDir=$(SolutionDir)\
-set targetDir=%25cd%25
-set psScriptsDir=$(SolutionDir)Tools
-set certPath=$(CertPath)
-set certPassword=$(CertPassword)
-@echo on
+
+IF "%25APPVEYOR_BUILD_FOLDER"=="" (set cert_pwd=$(CertPassword))
:: Call the post build powershell script
-powershell.exe -ExecutionPolicy Bypass -File "%25psScriptsDir%25\postbuild_mremotev1.ps1" -SolutionDir "%25solutionDir%25" -TargetDir "%25targetDir%25" -TargetFileName "mRemoteNG.exe" -ConfigurationName "%25buildenv%25" -CertificatePath "%25certPath%25" -CertificatePassword "%25certPassword%25" -ExcludeFromSigning "PuTTYNG.exe"
+powershell.exe -ExecutionPolicy Bypass -File "$(SolutionDir)Tools\postbuild_mremotev1.ps1" -SolutionDir "$(SolutionDir)\" -TargetDir "%25cd%25" -TargetFileName "mRemoteNG.exe" -ConfigurationName "%25buildenv%25" -CertificatePath "$(CertPath)" -CertificatePassword "%25cert_pwd%25" -ExcludeFromSigning "PuTTYNG.exe"
true