Hi,
I have used this viewtopic.php?f=21&t=14127 to generate an exe/msi.
They work fine on my local machine but not when launched on another (remote) machine (so f.e. opening test.xmind with the exe should show a window test.xmind). The exe launches but shows no output for the extension (it does when running locally).
Maybe I need to change the way I generate the exe/msi?
Thanks
S
Open document with exe of Sapien PS Studio
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.
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.
- Alexander Riedel
- Posts: 8478
- Last visit: Tue Mar 26, 2024 8:52 am
- Been upvoted: 37 times
Re: Open document with exe of Sapien PS Studio
You are going to have to provide a few more details on what you are doing. The exe and MSI generation seem to have no bearing on what you are describing.
Alexander Riedel
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
Re: Open document with exe of Sapien PS Studio
Thanks. I did change from a single form (psf) to a project after which it doesn't work.
The project has globals.ps1 and some other files. Where do I define the Params($args) in a Project vs single form -see link to previous post-, now they are in the pss file?
Note: the project has several forms which open depending on the param that is given
The project has globals.ps1 and some other files. Where do I define the Params($args) in a Project vs single form -see link to previous post-, now they are in the pss file?
Note: the project has several forms which open depending on the param that is given
Re: Open document with exe of Sapien PS Studio
Sorry, let me try again
The $commandarg is working fine it seems.
It is the reading of the extension that doesn't seem to work.
It works fine in Powershell studio, not when in an executable.
F.e. c:\mydocuments\test.exe shows form2 wheras it should show form1
The $commandarg is working fine it seems.
It is the reading of the extension that doesn't seem to work.
It works fine in Powershell studio, not when in an executable.
F.e. c:\mydocuments\test.exe shows form2 wheras it should show form1
- $Global:File = [io.fileinfo]$commandarg
- $Global:Extension = ([IO.Path]::GetExtension($File))
- $Global:FileName = [io.path]::GetFileName($File)
- $Global:Extension = ([IO.Path]::GetExtension($File))
- #Commandarg is shown correctly, but it does not show form1
- if ($($Extension -like '.exe') -or $($Extension -like '.msi'))
- {
- Show-Form1_psf
- } #exe or msi
- else
- {
- Show-Form2_psf
- }
Re: Open document with exe of Sapien PS Studio
The "Show" function will only exist if you add the form to the project correctly. Just adding it as a file it will not be a function and will not be visible in autocomplete.
Adding an external file to a forms project will require calling the forms PS1 file:
.\yourform.ps1
Adding an external file to a forms project will require calling the forms PS1 file:
.\yourform.ps1
Re: Open document with exe of Sapien PS Studio
Thanks, the show is not the problem. Both forms show correctly when called.
The variable file is not recognized, args is recognized, but I can t get the args into extension, FileName, path.
In otter words: "If extension" does not work. It always shows the same form.
The variable file is not recognized, args is recognized, but I can t get the args into extension, FileName, path.
In otter words: "If extension" does not work. It always shows the same form.
Re: Open document with exe of Sapien PS Studio
There is still no way to understand what you are asking. What arguments? WHere are they defined? Where are you trying to use them?
Again - we need an full code example that is simple and demonstrates what is wrong.
What is $commandarg? Where is it defined?
Again - we need an full code example that is simple and demonstrates what is wrong.
What is $commandarg? Where is it defined?
Re: Open document with exe of Sapien PS Studio
Hope this makes it clear.
When the project starts as exe, it should read the argument passed to it (dragging a file to it). Then when it should open form1,form2 or form3 based upon the argument passed.
F.e. if it is .exe it should open formx, when no argument formy, else formz.
When the project starts as exe, it should read the argument passed to it (dragging a file to it). Then when it should open form1,form2 or form3 based upon the argument passed.
F.e. if it is .exe it should open formx, when no argument formy, else formz.
- Attachments
-
- Example.zip
- Example project
- (91.61 KiB) Downloaded 86 times
Re: Open document with exe of Sapien PS Studio
The following works fine for me:
Code: Select all
function Main {
Param ($commandarg)
$file = [system.io.directoryinfo]$commandarg
if (! $commandarg){
Show-Form1_psf
}elseif($file.Extension -match 'exe|msi'){
Show-Form2_psf
}else{
[System.Windows.Forms.MessageBox]::Show($commandarg)
Show-Form3_psf
}
$script:ExitCode = 0 #Set the exit code for the Packager
}
Re: Open document with exe of Sapien PS Studio
I was wondering why this was so hard for you but I realize that complex logic can be difficult for non-programmers.
Here is another approach that may help you to see what is happening here:
I should also note that $commandarg is only defined in thtat one function so it may have been that you were trying to use it elsewhere or that you had created your own variable with that name.
Here is another approach that may help you to see what is happening here:
Code: Select all
function Main {
Param ($commandarg)
switch -regex ($commandarg){
'^$' {Show-Form1_psf}
'\.exe$|\.msi$' {Show-Form2_psf}
default {Show-Form3_psf}
}
$script:ExitCode = 0 #Set the exit code for the Packager
}