How do you install dependent programs with a batch file? - winapi

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.

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 :-)

How can I run a robot test suite with Windows environment variable using pycharm terminal?

I setup an environment variable in Windows 10 called ROBOT_HOME and it points to my D:\Robot
When I run the test in my PyCharm terminal I use the following command -
robot --test "Example" %ROBOT_HOME%/test-cases
I require these environment variables as it is used company wide and they all call the same ROBOT_HOME and it needs to be defined in each Windows machine locally for it to work.
I am using the Intellibot#master.dev plugin in PyCharm.
It used to work until yesterday (as part of the robot course I'm going through, we used a diff robot framework plugin for PyCharm and now, even reverting back to the previous plugin, it won't work).
I keep getting "File Or Directory does not exist".
When I run the same command in command prompt, it works.
It used to work in the PyCharm terminal as well, not anymore.
In case it's worth mentioning, the PyCharm terminal is Windows Powershell.
In order to call an environment variable from the Powershell terminal in PyCharm, I needed to use the powershell env variable call -
$env:ROBOT_HOME
To see existing variable, can use the following command -
dir env:

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

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.

Matlab compiled .exe cannot run with task scheduler but can run with double-click

I have a matlab compiled .exe file, it can run well with double-click, but when run with task scheduler, the following error pops out:
while actually I have installed the 7.17 of MCR, otherwise it will not run with double click. Anyone can help with this? Thanks a lot!
You need to include the MCR installation folder on the PATH environment variable. See here for instructions how (you might need to log off/on for it to take effect).
Note that if you are using the SET command in the command prompt, changes made are not permanent, and they would apply to the current CMD prompt only and remain only until the command prompt is closed.

jenkins: windows xp, windows 7 slave cannot execute commands

I have a Arch Linux master that drive 2 arch linux slaves, 1 windows xp slave and 1 windows 7 slave. Linux part is all ok, I managed in some way to start windows slave using automatic execution and slave.jar. I have an external program that need to be executed and it's installed on c:\program files (x86) on windows7 and on c:\programs on windows xp.
I went on path variables and inserted the two path on the two systems, but when I try to run jenkins build it says "command not found"
I tryed to place 2 bat files in c:\ poining to the right place, based on every system, but it says c:\build.bat command not found. I can see the file in the right place...
How do you manage executables placed in different places on different computers?
there's a better way to run the program?
I can change everything about this installation, the only thing I need it to find a way for starting that program.
thank you for your help.
Have you verified that the changes you made to the system path were actually saved? Make sure both of the slaves have been rebooted and then test this via a standard command line window.
If the program you're trying to execute is actually on the path, you could also look at the Envfile Plugin.
After adding new paths to your environment variable PATH you need to restart jenkins slave service in order to allow it to use these new PATHs.
I solved the problem changing the way jenkins start the job on the slave. I used "Execute shell" and some program are executed. I changed "Execute shell" with "Execute windows batch command" and everything works fine.

Resources