/build/static/layout/Breadcrumb_cap_w.png

How to pass a parameter into an EXE to an MSI using powershell

OK, after much trial and all error I have decided to ask for assistance. This is my first post so please be gentle.

I am trying to deploy IBM Data Server Runtime Client 10.5. The issue is that to deploy the application silently you need a response file and the install command for that response file must be an absolute path and not relative. We are using SCCM to deploy the app, which could place it in a different subfolder within CCMCACHE on each machine.

I can hard code a path and the following command works:

  • v10.5fp6_ntx64_rtcl_EN.exe  /v"/l*v %windir%\Key_Logs\IBM_DATA_SERVER_RUNTIME_CLIENT_10.5fp6_Install.log /qn RSP_FILE_PATH=<hard coded path>\DB2RTC_Install.rsp"

What I am trying to do is use powershell to enumerate the path that the response file resides in when placed in CCMCACHE (also the location where the powershell command would be run from). I have tried many different ways to do this, but they all seem to fail. Obviously my powershell skills are lacking or my understanding is not sufficient to make it work.

Here is what I am working around. Like I have said, I have tried many different iterations around this script, like variablizing most of the commands

  •  

    #This script is required because the installation of the DB2 Runtime client will not accept relative paths to the response file

    #We need to enumerate the relative path as a variable and pass the variable into the RSP_FILE_PATH= argument.

    $SourceDir = (Get-Item -Path ".\" -Verbose).FullName #determines what SCCM folder install files are in

    Start-Process -FilePath "$SourceDir\v10.5fp6_ntx64_rtcl_EN.exe" -ArgumentList '/v" /l*v %windir%\Key_Logs\DB2RTC_10.5Fp6_Install.log /qn RSP_FILE_PATH=' + $SourceDir + '\DB2RTC_Install.rsp"' -Wait



Any help would be greatly appreciated



0 Comments   [ + ] Show comments

Answers (2)

Answer Summary:
Posted by: dunnpy 7 years ago
Red Belt
1

Top Answer

Does it work correctly with a manual install if you create the response file in one location and then move the installer to another location - to mimic how it would be in a different directory when installing through SCCM?

The reason I ask is that Oracle uses .rsp files, and they capture the location that the .rsp file was created in, in the file itself.
You have to modify a FROM_LOCATION to a relative path otherwise it will only install from the path the .rsp was created in - see this post for more information - your .rsp file may be different, but it's worth bearing in mind.

How about a simple batch file to confirm your approach is correct? %~dp0 will give you the current path:

RSP_FILE_PATH="%~dp0DB2RTC_Install.rsp"

Dunnpy

Comments:
  • OMG, too simple. Here I was making it all complicated. It appears that this solution works.
    Instead of creating a powershell script to deploy the app, I created a simple batch file and placed it in the diectory where the response file resides. Inside the batch was my install command with your suggested modification.
    Additionally I was able to install it from another location with a slight modification to the response file.

    Thank you for your time to assist me. - tropheusman 7 years ago
Posted by: rileyz 7 years ago
Red Belt
0

Don’t have much time to reply, so straight to it.

 

This will help, plug this in

$Invocation = (Get-Variable MyInvocation).Value
$Invocation.MyCommand
$SourceDir = Split-Path $Script:MyInvocation.MyCommand.Path

 

 

Also in regards to running exe in PowerShell, the correct and preferred way to launch a exe is to use the & symbol, only use Start-Process if the process is not waiting correctly. The ampersand ensures the switches and arguments are eaten up by the exe correctly - plus its a hell of a lot easier to read

 

For example

& cmd /c "echo hello world"

 

Regards to style, try and use single quotes, and only use double quotes when you need to expand a variable.

 

 

 

This is to help with your issue, I haven’t really digested your issue - no time, so there will probably be better methods to what you want to achieve.


Comments:
  • Thank you for your assitance. - tropheusman 7 years ago
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ