How to install oracle jdk 7 silently in script with dependency? - windows

I am trying script the install for Glassfish on a 64bit windows 2008 r2 server. But in order to install that, I need a JDK. Therefore, I am trying to silently install JDK 7 (u21) prior to glassfish. My problem I'm finding is that when I kick off the install using the following command, the command line immediately returns, so I have no way of knowing from the command line when the install is complete as it appears to run in the background.
REM Copy jdk installer and run silently
copy x:\java\glassfish\windows\jdk-7u21-windows-x64.exe jdk.exe
jdk.exe /s
My next step then immediately kicks off prior to my jdk being installed, which causes the glassfish installer to fail.
copy x:\java\glassfish\windows\glassfish-3.1.2.2-windows.exe glassfish.exe
REM command to silently install GF goes here
Is there a flag I can pass in to the jdk installer to force it to not run in the background, so that when my script is able to run the next command, I am certain that the JDK is installed?
Or does the very nature of running it silently mean that it will simply run in the background and there's no way around it? And if this is the case, any thoughts on how I could get my script to wait for the jdk to complete prior to continuing?

use START with the WAIT par, ie
START /WAIT jdk.exe /s
Start is an internal command to cmd.

Related

Installing Windows Service fails when command run in batch file

I'm converting a legacy VC 6 C++ Windows Service application to Visual Studio 2022
The conversion is completed and, if I open a CMD prompt with Admin rights, I can install the service using this command:
Service.exe /Install
It installs instantly and starts correctly.
However, I need to install it within an installation script, which loads a bunch of services by calling a batch file which contains the commands to start them. It is run with elevated permissions. However, which it reaches the above line (Service.exe /Install) it hangs. There is no error message and I cannot even terminate it using CTRL + C. The only way around it is to close the CMD prompt. The service is not installed.
My service does not appear in the Task manager's list of processes when the batch file hangs.
I've tried adding the full path to the service in the batch file but it makes no difference. Running this batch file from an elevated command prompt (rather than the installer script) runs into the same problem.
I'm tearing my hair out over this (almost bald now :-)) - can anyone provide any suggestions?
Thanks
Andy
Debugging found a logic error in the start up code.
Basically, calling Service.exe /Install directly from the command line just passes "Service.exe /Install" as the command line, whereas calling it from a batch file / CreateProcess() passes the whole path to the service in the command line and the parser was not taking that into account. Maybe it behaved differently in older Windows versions, but the parser was really badly written.
I'm glad it was me who wrote it :-)

MSI not upgrading when ran under system account

I am running an MSI on a remote machine using PsExec using this command:
psexec -accepteula \\$(remote-machine-fqdn) -s cmd /c "msiexec.exe /qn /I $(path-to-msi) /Lv $(path-to-log-file)"
This works fine the first time, in that installs the application.
However, subsequent runs (and this is being run as part of a CI build in TFS) causes multiple versions of the application to appear in 'Add and Remove Programs'. If I run the installers myself (log on to the server, click on the MSI, etc.), then it upgrades correctly so the problem does not appear to be in installer itself.
I think the problem is to do with running as the system account (the -s switch in the PsExec command), but I can see no reason why this should be happening. Anyone seen this before?
Try passing ALLUSERS=1 public property to msi while fresh and upgrade installations.

Batch as a windows service

I am running a Jenkins on windows machine with the process of Jenkins.war.
'java -jar jenkins.war'. If I close the command prompt of the service, Jenkins will go down. I want the Jenkins to be up even if the command prompt closed and even after machine reboot, this jenkins to be started. How can we do this on windows machine?
You can use create-windows-service-from-executable to make your jenkins.exe as a service. Or else while installing itself, install as a service rather than starting from command line

How do you install dependent programs with a batch file?

I'd like to install two programs (program.exe, program_sp1.exe) via batch script.
The problem is that the first install adds environment variables that are needed by the 2nd.
Is there a good way to run the 2nd installer in a new command prompt so the values are picked up, but without user interaction to close it?
I've tried this in a Windows 7 Machine.
You should be able to run program.exe and the run cmd and then run your program_sp1.exe, and an exit as the cmd is running another version in itself with the updated environment variables.

Suppress the reboot prompt for the .NET 3.5 SP1 redist

I have an InstallShield 2009 Basic MSI project that I've modified to load the 3.5 SP1 redistributable for the .NET framework. It loads fine but as soon as it finishes it displays a prompt saying the system has to reboot, and you can either say yes and it will reboot, or no and it will stop the install.
I then went in and edited the .NET Framework 3.5 Service Pack 1 (Web Download) redistributable using InstallShield's prerequisite editor. I changed the behavior if it needs a reboot to 'Note it, fail to resume if the machine is rebooted, and reboot after the installation'. I interpreted that as meaning the reboot prompt would not be shown until the end of the install, but it still showed up in the same place.
Is there a way to suppress the prompt until the end of the install? Do I need to pick a different option from that drop-down in the pre-req editor?
Bonus question: if I need to run my install unattended, is there a way to automatically have it reboot after the entire install is finished if one is needed?
EDIT:
The command switches mentioned below would probably work, but in the case of running the install unattended it will be launched from another program, and I really don't want to modify that app just for this one case. Here's a better question: is a reboot really required after installing .NET 3.5 SP1, or is it one of those things where a reboot would be good but is not absolutely needed for programs to start using the 3.5 framework?
If you type msiexec /? in the Start -> Run box, you'll get a screen with command line options for the MSI runtime, including the following:
Restart Options
/norestart
Do not restart after the installation is complete
/promptrestart
Prompts the user for restart if necessary
/forcerestart
Always restart the computer after installation
You can suppress the reboot prompt entirely by adding the following to the MSI's setup command line:
REBOOT=ReallySuppress
But then it won't prompt at the end of your complete install, as it sounds like you were hoping for; you're just stopping the prompting altogether.
As for your additional question, you can force a reboot with the following switch:
REBOOT=Force REBOOTPROMPT=Supress
Here you're telling the Windows Installer to prompt for a reboot always, and then suppressing the prompt so it just happens.

Resources