HowTo: Path to MSI application files and getting them to execute?

Ask your PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 4 years and 9 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
shiroscout
Posts: 41
Last visit: Sat Jul 15, 2023 7:13 pm

HowTo: Path to MSI application files and getting them to execute?

Post by shiroscout »

Hello,

I believe this is a command issue, but I am paving the the issue with an explanation.
When I am in PSS the .cmd and .bat files popup in a prompt box, run, then exit, but I get no visual sign of anything executing after packaging msi files.
I cannot get MSI external files to execute.

I went through the tab settings of the MSI packager.
Really, mostly took the defaults.

The program installs in:
C:\Program Files\Company\Product
Like:
C:\Program Files\Adobe\Photoshop

Apparently PPS does not create the sub-folder structure but dumps all the files in the root product name folder.OK, I can deal with that.

What I would like to know is how do I correctly point the button commands to execute the external files? The files are .cmd, .bat, and a few others but I think if I were given 1 good working example, I might be able to figure the rest out.

When pointing to the files from within PSS I can use multiple ways and they launch: Call & , Start-Process, Invoke-Item, etc... but literally after doing the packaging MSI and installing everything that is an external file does not launch.

Anything that is a windows internal tool, a windows native utility, powershell commands all work.

There is something important that I am trying to accomplish in that I do not desire full hard paths. I am trying to be able to have my path detect at folder product which would be my root folder of script and external files. That way the folder can be installed via MSI, or I can package it in a zip and it will work wherever it is extracted at.

I've tried these type examples:

Code: Select all

$buttonDisableStartupRepair_Click={
	#TODO: Place custom script here
	$richtextbox1.Text =
	# Invoke-Item -Path
	# Start-Process -FilePath
	Start-Process -FilePath "$PSScriptRoot\Bat\DisableStartupRepair.Bat" -PassThru | Out-String
}

$buttonGetWindowsUpdates_Click= {
	#TODO: Place custom script here
	$richtextbox1.Text =
	#invoke-expression 'cmd /c start powershell -NoExit -Command ".\\ImportPs1\AutoWinUpdates.ps1"' | Out-String
	Start-Job -ScriptBlock { . $PSSriptroot\ImportPs1\AutoWinUpdates.ps1 } -Name 'WinUpdates' | Out-String
	#Start-Job -ScriptBlock { . .\ImportPs1\AutoWinUpdates.ps1 | Out-String }
	
}


$buttonUpdateMcAfeeVirusDef_Click={
	#TODO: Place custom script here
	$richtextbox1.Text =
	# Invoke-Item -Path ".\Bat\McAfeeUpdater.cmd"
	Invoke-Item -Path "McAfeeUpdater.cmd" | Out-String
}

$buttonRunCFGMGRActionItems_Click={
	#TODO: Place custom script here
	$richtextbox1.Text =
	Start-Process -FilePath "$PSScriptRoot\CfgMgrActionItems.cmd" -PassThru | Out-String
	# Invoke-Item -Path ".\Bat\CfgMgrActionItems\CfgMgrActionItems.cmd"
	
}
and I have tried several other ways.But I am confused because many of these command launch and I see a prompt box popup, execute commands and then exit when in PSS but after packaging msi and trying same commands nothing happens.
Attachments
ShiroScout3.PNG
ShiroScout3.PNG (71.91 KiB) Viewed 4710 times
ShiroScout2.PNG
ShiroScout2.PNG (21.82 KiB) Viewed 4710 times
ShiroScout.PNG
ShiroScout.PNG (17.68 KiB) Viewed 4710 times
Last edited by shiroscout on Tue Jun 18, 2019 6:15 pm, edited 1 time in total.
Thank You,

Wayne
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: HowTo: Path to MSI application files and getting them to execute?

Post by jvierra »

An MSI does not execute external files so it is hard to understand what it is that you expect and what you are trying to do.
The Sapien packager and installer is used to install packaged scripts. It is not a general purpose installer.
User avatar
shiroscout
Posts: 41
Last visit: Sat Jul 15, 2023 7:13 pm

Re: HowTo: Path to MSI application files and getting them to execute?

Post by shiroscout »

Hello,

Yes, thank you, I understand what you are saying but that is not what I am trying to do.

I just need to know what the path is to the files if I am installing at:
C:\Program Files\ZimbaRush\ShiroScout

What path do I use in my main form, see examples please, for the button commands, because the buttons work and run the .cmd, .bat and other files until I get done packaging them, installing MSI, then on launch the buttons appear to do nothing.

I thought I should simply be able to put as executable path "$ScriptRoot\<file-to-execute>
Thank You,

Wayne
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: HowTo: Path to MSI application files and getting them to execute?

Post by jvierra »

You have to know the path in advance if it is not $PsScriptRoot.

The installer knows paths but external programs and scripts don't know what the installer knows.
User avatar
Alexander Riedel
Posts: 8478
Last visit: Tue Mar 26, 2024 8:52 am
Answers: 19
Been upvoted: 37 times

Re: HowTo: Path to MSI application files and getting them to execute?

Post by Alexander Riedel »

Just use a relative path. If your batch file is in the same location as the executable, just use
./myscript.bat

Nothing complicated about that
Alexander Riedel
SAPIEN Technologies, Inc.
User avatar
Alexander Riedel
Posts: 8478
Last visit: Tue Mar 26, 2024 8:52 am
Answers: 19
Been upvoted: 37 times

Re: HowTo: Path to MSI application files and getting them to execute?

Post by Alexander Riedel »

If the current folder is NOT where your exe is, look at the GetScriptPath snippet.
Alexander Riedel
SAPIEN Technologies, Inc.
This topic is 4 years and 9 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked