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

Ask your Windows 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.
Locked
User avatar
smjadtnf707
Posts: 32
Joined: Sun May 19, 2019 7:26 pm

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

Post by smjadtnf707 » Tue Jun 18, 2019 5:52 pm

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 1624 times
ShiroScout2.PNG
ShiroScout2.PNG (21.82 KiB) Viewed 1624 times
ShiroScout.PNG
ShiroScout.PNG (17.68 KiB) Viewed 1624 times
Last edited by smjadtnf707 on Tue Jun 18, 2019 6:15 pm, edited 1 time in total.
Thank You,

Wayne

User avatar
jvierra
Posts: 13682
Joined: Tue May 22, 2007 9:57 am
Contact:

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

Post by jvierra » Tue Jun 18, 2019 6:14 pm

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
smjadtnf707
Posts: 32
Joined: Sun May 19, 2019 7:26 pm

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

Post by smjadtnf707 » Tue Jun 18, 2019 6:21 pm

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

User avatar
jvierra
Posts: 13682
Joined: Tue May 22, 2007 9:57 am
Contact:

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

Post by jvierra » Tue Jun 18, 2019 6:34 pm

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: 7001
Joined: Tue May 29, 2007 4:43 pm

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

Post by Alexander Riedel » Thu Jun 20, 2019 12:50 am

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: 7001
Joined: Tue May 29, 2007 4:43 pm

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

Post by Alexander Riedel » Thu Jun 20, 2019 12:52 am

If the current folder is NOT where your exe is, look at the GetScriptPath snippet.
Alexander Riedel
SAPIEN Technologies, Inc.

Locked