Page 1 of 1

Buildversion, use exeversion to show in GUI?

Posted: Thu Feb 20, 2020 5:43 am
by stevens
Hi,

I convert my powershell GUI into an exe/msi and use the 'auto-increment' of exe, then use exe for version in msi.
First: if generating MSI, should I first generate exe or will the msi creation generate the exe (I think I should, but just checking)?
Second: I'd like to show the version in the form header (I put it into the globals.ps1 now $Version ='1.0.0.0', then at formload, Title = $version ...
Can I read the version somewhere from a variable instead of putting the version into the globals.ps1?

Thanks!

Re: Buildversion, use exeversion to show in GUI?

Posted: Thu Feb 20, 2020 6:31 am
by jvierra
I recommend posting issues of how to use PSS to the Customer Support forum for PSS. Sapien techs will answer your questions about the product itself. The Community Forums are for PowerShell specific questions/

Re: Buildversion, use exeversion to show in GUI?

Posted: Mon Apr 06, 2020 4:29 pm
by Nillth
you can call the following from inside your script.
It will pull determine the running file and pull the version info from it.

Code: Select all

$RuntimeFileInfo = Get-Item $hostinvocation.MyCommand.path
$RuntimeVersion = $($RuntimeFileInfo.VersionInfo.ProductVersion)

Re: Buildversion, use exeversion to show in GUI?

Posted: Tue Apr 07, 2020 1:33 am
by stevens
Thanks Nillth, works like a charm!!!

Re: Buildversion, use exeversion to show in GUI?

Posted: Fri Apr 24, 2020 6:49 am
by stevens
It worked fine, but it appears my GUI throws errors on that code all the time.
When running the GUI via console, I see errors all the time which makes that my gui takes up to a minute to load :-(

l\Globals.ps1:330 char:29
+ $RuntimeFileInfo = Get-Item $hostinvocation.MyCommand.path
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Get-Item], ParameterBindingValidat
ionException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Micro
soft.PowerShell.Commands.GetItemCommand

Re: Buildversion, use exeversion to show in GUI?

Posted: Fri Apr 24, 2020 10:51 am
by jvierra
I repeat myself. In pojects use the following function to get teh script path.

Get-ScriptDirectory

It is the only way to get the path both as a script and as a package.

Re: Buildversion, use exeversion to show in GUI?

Posted: Mon Apr 27, 2020 12:08 am
by stevens
Ok, thanks.

Re: Buildversion, use exeversion to show in GUI?

Posted: Mon Apr 27, 2020 12:25 am
by jvierra
stevens wrote:
Mon Apr 27, 2020 12:08 am
No idea what you are trying to say.
The code that is erring won't work outside of an EXE.

What is it that you want the version of? PowerShell? A file? Windows?

Re: Buildversion, use exeversion to show in GUI?

Posted: Mon Apr 27, 2020 12:31 am
by jvierra
To get the current EXE version
[system.diagnostics.process]::GetCurrentProcess().ProductVersion

To get the file version:
[system.diagnostics.process]::GetCurrentProcess().MainModule.FileVersion