Reputation: 11
How do I get this script to go to INSTALLAX when the Framework is already installed? It installs the Framework even if it already exists.
What am I missing?
Echo off
IF EXIST "%Programfiles(x86)%" (GOTO 64-Bit) ELSE (GOTO 32-Bit)
:32-Bit
IF EXIST "%windir%\Microsoft.NET\Framework\v4.0.30319\SetupCache\Extended\setup.exe" GOTO INSTALLAX ELSE GOTO INSTALLFRAMEWORK
:64-Bit
IF EXIST "%windir%\Microsoft.NET\Framework64\v4.0.30319\SetupCache\Extended\setup.exe" GOTO INSTALLAX ELSE GOTO INSTALLFRAMEWORK
:INSTALLFRAMEWORK
start "" /w "\\server1\appdata01\Deployment\MicrosoftDynamicsAX\Prerequisites\Net Framework 4.0\dotNetFx40_Full_x86_x64.exe" /q /norestart
ECHO .NETFramework4.0Installed %Date% %TIME% >> \\server1\appdata01\Deployment\MicrosoftDynamicsAX\Client_Log\Framework\%COMPUTERNAME%.log
:INSTALLAX
start "" /w "\\server1\appdata01\Deployment\MicrosoftDynamicsAX\DynamicsAX\setup.exe" RunMode=Custom HideUI=1 AcceptLicenseTerms=1 ByPasswarnings=0 InstallClientUI=1 ClientAOSServer=ax-aos02-prod AOSPort=2712 AOSWsdlPort=8101 ClientLanguage=en-us ConfigurePrerequisites=1 ClientConfigFile="\\sespfs01\appdata01\Deployment\MicrosoftDynamicsAX\AX_Icons\DAX_Prod(usr)32-bit.axc" LogDir="\\server1\appdata01\Deployment\MicrosoftDynamicsAX\Client_Log"
ECHO AXDynamics2012Installed %Date% %TIME% >> \\server1\appdata01\Deployment\MicrosoftDynamicsAX\Client_Log\AXDynamics\%COMPUTERNAME%.log" GOTO END
:END
Exit
Upvotes: 1
Views: 14029
Reputation: 20464
Your problem is obvious:
IF EXIST "%windir%\Microsoft.NET\Framework64\v4.0.30319\SetupCache\Extended\setup.exe" GOTO INSTALLAX GOTO INSTALLFRAMEWORK
no ELSE in the conditional.
And in the subs ":INSTALLFRAMEWORK" and ":INSTALLAX" you are not telling to exit the procedure so ":INSTALLAX" is always processed.
Also in the ":INSTALLAX" procedure you are using two commands without using the concatenate operator "&" (Echo blabla >> file goto blabla)
Here is the code:
@Echo off
Set "FW32=%windir%\Microsoft.NET\Framework\v4.0.30319\SetupCache\Extended\setup.exe"
Set "FW64=%windir%\Microsoft.NET\Framework64\v4.0.30319\SetupCache\Extended\setup.exe"
IF EXIST "%Programfiles(x86)%" (
REM 64BIT
IF EXIST "%FW64%" (GOTO :INSTALLAX) ELSE (GOTO :INSTALLFRAMEWORK)
) ELSE (
REM 32BIT
IF EXIST "%FW32%" (GOTO :INSTALLAX) ELSE (GOTO :INSTALLFRAMEWORK)
)
:INSTALLFRAMEWORK
start "" /Wait "\\server1\appdata01\Deployment\MicrosoftDynamicsAX\Prerequisites\Net Framework 4.0\dotNetFx40_Full_x86_x64.exe" /q /norestart
ECHO .NETFramework4.0Installed %Date% %TIME% >> "\\server1\appdata01\Deployment\MicrosoftDynamicsAX\Client_Log\Framework\%COMPUTERNAME%.log"
Pause&Exit
:INSTALLAX
start "" /Wait "\\server1\appdata01\Deployment\MicrosoftDynamicsAX\DynamicsAX\setup.exe" RunMode=Custom HideUI=1 AcceptLicenseTerms=1 ByPasswarnings=0 InstallClientUI=1 ClientAOSServer=ax-aos02-prod AOSPort=2712 AOSWsdlPort=8101 ClientLanguage=en-us ConfigurePrerequisites=1 ClientConfigFile="\\sespfs01\appdata01\Deployment\MicrosoftDynamicsAX\AX_Icons\DAX_Prod(usr)32-bit.axc" LogDir="\\server1\appdata01\Deployment\MicrosoftDynamicsAX\Client_Log"
ECHO AXDynamics2012Installed %Date% %TIME% >> "\\server1\appdata01\Deployment\MicrosoftDynamicsAX\Client_Log\AXDynamics\%COMPUTERNAME%.log"
Pause&Exit
Upvotes: 2
Reputation: 19602
You already did it right in the first IF statement (using parenthesis).
:32-Bit
IF EXIST "%windir%\Microsoft.NET\Framework\v4.0.30319\SetupCache\Extended\setup.exe"
(GOTO INSTALLAX) ELSE (GOTO INSTALLFRAMEWORK)
:64-Bit
IF EXIST "%windir%\Microsoft.NET\Framework64\v4.0.30319\SetupCache\Extended\setup.exe"
(GOTO INSTALLAX) ELSE (GOTO INSTALLFRAMEWORK)
(added newline for readability only)
Also, you were missing an ELSE.
Upvotes: 0