Error when running executable generated by Powershell Studio
Forum rules
DO NOT POST LICENSE NUMBERS, ACTIVATION KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.
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 LICENSE NUMBERS, ACTIVATION KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Error when running executable generated by Powershell Studio
Build: v5.8.196
OS: Windows Server 2019 (64 Bit)
Build: v10.0.19044.0
PowerShell version(s): 5.1.17763.2268
I wrote a service in Powershell that will run fine on it's own as a .ps1 file.
After compiling it in Powershell studio 2021 I get the following error if I run the .exe with a '/i' switch. I also receive the same error if I deploy it as an MSI file. The error shows up in the event log as expected.
Line 79: The term 'that' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
The Line 79 in the error is not from my script and the "that" command it's attempting to find is also not in m y script.
I have upgraded to the latest and greatest. resaved by work and recompiled but the results are the same. I wrote this on my Windows 10 laptop but I'm running it on a Windows Server 2019 VM.
Last edited by jcranecw on Tue Dec 14, 2021 12:28 pm, edited 1 time in total.
- Alexander Riedel
- Posts: 8479
- Last visit: Thu Mar 28, 2024 9:29 am
- Been upvoted: 37 times
Re: Error when running executable generated by Powershell Studio
Can you please upload the .psbuild file or email it to support@sapien.com?
Alexander Riedel
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
Re: Error when running executable generated by Powershell Studio
Just attached the .psbuild file to the original post.
- Alexander Riedel
- Posts: 8479
- Last visit: Thu Mar 28, 2024 9:29 am
- Been upvoted: 37 times
Re: Error when running executable generated by Powershell Studio
The .PsBuild file indicates that the installer settings have no entries for installing a service. Please refer to the "Services" section in the SAPIEN Script Packager.
Since you say the packaged service is not operating even prior to installing, please show the output of the packaging process.
If this shows no errors or warnings, please submit the code you are actually using.
You can do this privately here: https://www.sapien.com/support/upload
Since you say the packaged service is not operating even prior to installing, please show the output of the packaging process.
If this shows no errors or warnings, please submit the code you are actually using.
You can do this privately here: https://www.sapien.com/support/upload
Alexander Riedel
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
Re: Error when running executable generated by Powershell Studio
I used the create a service template when I wrote the script. My assumption is that basic settings would have been included with the template. The script is attached here and I have uploaded the generated MSI file to the link in the previous post.
Here is the output from the package build...
>> MSI 'C:\Users\jcrane\OneDrive - CloudWave\Documents\SAPIEN\PowerShell Studio\Files\CwClusterMon\CwClusterMon.ps1'
SAPIEN Package and Deploy Tool 4.5 (c) 2005 - 2021 SAPIEN Technologies, Inc.
Processing input files...
Processing settings...
Building MSI file...
MSI file C:\Users\jcrane\OneDrive - CloudWave\Documents\SAPIEN\PowerShell Studio\Files\CwClusterMon\CwClusterMon.msi created.
>> Completed
Here is the output from the package build...
>> MSI 'C:\Users\jcrane\OneDrive - CloudWave\Documents\SAPIEN\PowerShell Studio\Files\CwClusterMon\CwClusterMon.ps1'
SAPIEN Package and Deploy Tool 4.5 (c) 2005 - 2021 SAPIEN Technologies, Inc.
Processing input files...
Processing settings...
Building MSI file...
MSI file C:\Users\jcrane\OneDrive - CloudWave\Documents\SAPIEN\PowerShell Studio\Files\CwClusterMon\CwClusterMon.msi created.
>> Completed
- Attachments
-
- CwClusterMon.ps1
- (7.82 KiB) Downloaded 80 times
- Alexander Riedel
- Posts: 8479
- Last visit: Thu Mar 28, 2024 9:29 am
- Been upvoted: 37 times
Re: Error when running executable generated by Powershell Studio
Thank you for uploading your files.
I have extracted the code from the service executable in your installer and found the following text. This explains the error your are seeing.
The code in your exe does not correspond to the script you submitted here in this forum.
From the output you submitted it appears you are rebuilding the installer but not the service executable.
Please understand that
a) building the executable and
b) building the installer
are two distinct different processes.
Build All (F7) usually would combine all necessary steps.
Furthermore, the installer your provided and the .psbuild file indicate that the service executable is not selected as a service for the MSI.
Please make sure you visit the "Service" section in the MSI builder to add the service executable and corresponding settings there.
I have extracted the code from the service executable in your installer and found the following text. This explains the error your are seeing.
The code in your exe does not correspond to the script you submitted here in this forum.
From the output you submitted it appears you are rebuilding the installer but not the service executable.
Please understand that
a) building the executable and
b) building the installer
are two distinct different processes.
Build All (F7) usually would combine all necessary steps.
Furthermore, the installer your provided and the .psbuild file indicate that the service executable is not selected as a service for the MSI.
Please make sure you visit the "Service" section in the MSI builder to add the service executable and corresponding settings there.
Alexander Riedel
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
Re: Error when running executable generated by Powershell Studio
I agree the code in the .exe does not correspond to what's in the script.
I also understand that building the executable and the MSI are separate processes.
Just to verify what I'm doing I ran a build all (see the result below)
I still have the same problem. It looks like the code is being scrambled during the compile.
The statement you pointed out as my problem is inside a comment block. It should not be separated out.
John C.
------ Build started: CwClusterMon, Configuration: x64 ------
Packaging with SAPIEN PowerShell V5 Host (Windows Service) x64
Adding C:\Users\jcrane\OneDrive - CloudWave\Documents\SAPIEN\PowerShell Studio\Files\CwClusterMon\CwClusterMon.ps1
Including external script createjson.ps1
Writing scripts to bin\x64\CwClusterMon.exe
Warning: No custom manifest specified.
Package completed
Processing input files...
Processing settings...
Building MSI file...
MSI file C:\Users\jcrane\OneDrive - CloudWave\Documents\SAPIEN\PowerShell Studio\Files\CwClusterMon\CwClusterMon.msi created.
0 error(s), 1 warning(s)
I also understand that building the executable and the MSI are separate processes.
Just to verify what I'm doing I ran a build all (see the result below)
I still have the same problem. It looks like the code is being scrambled during the compile.
The statement you pointed out as my problem is inside a comment block. It should not be separated out.
John C.
------ Build started: CwClusterMon, Configuration: x64 ------
Packaging with SAPIEN PowerShell V5 Host (Windows Service) x64
Adding C:\Users\jcrane\OneDrive - CloudWave\Documents\SAPIEN\PowerShell Studio\Files\CwClusterMon\CwClusterMon.ps1
Including external script createjson.ps1
Writing scripts to bin\x64\CwClusterMon.exe
Warning: No custom manifest specified.
Package completed
Processing input files...
Processing settings...
Building MSI file...
MSI file C:\Users\jcrane\OneDrive - CloudWave\Documents\SAPIEN\PowerShell Studio\Files\CwClusterMon\CwClusterMon.msi created.
0 error(s), 1 warning(s)
- Alexander Riedel
- Posts: 8479
- Last visit: Thu Mar 28, 2024 9:29 am
- Been upvoted: 37 times
Re: Error when running executable generated by Powershell Studio
Remove this line from your comments
2. The install includes a script called CreateJson.ps1 that can be edited to create the configuration you need
And see what that does please.
2. The install includes a script called CreateJson.ps1 that can be edited to create the configuration you need
And see what that does please.
Alexander Riedel
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
Re: Error when running executable generated by Powershell Studio
I did not remove the comment from the file since it's there for a reason. I did however change the comment from a block to individually commented lines and that at least changed the problem.
Now I get what looks like a real Powershell error...
Line 56: Cannot bind argument to parameter 'Path' because it is an empty string.
Once again I was able to copy the script to the system and run it manually be adding a line at the bottom that invokes the Start-MyService function so not sure that this is a script error. The line number in the error does not appear to be a line number from the script. It looks like it's from the executable or the code that actually generated the executable.
I don't have anything that can extract code from the service executable so I'm unable to take a look there.
Any help tracing the error back would be appreciated.
John C.
Now I get what looks like a real Powershell error...
Line 56: Cannot bind argument to parameter 'Path' because it is an empty string.
Once again I was able to copy the script to the system and run it manually be adding a line at the bottom that invokes the Start-MyService function so not sure that this is a script error. The line number in the error does not appear to be a line number from the script. It looks like it's from the executable or the code that actually generated the executable.
I don't have anything that can extract code from the service executable so I'm unable to take a look there.
Any help tracing the error back would be appreciated.
John C.
- Alexander Riedel
- Posts: 8479
- Last visit: Thu Mar 28, 2024 9:29 am
- Been upvoted: 37 times
Re: Error when running executable generated by Powershell Studio
Please see: https://www.sapien.com/blog/2009/09/02/ ... nvocation/
MyInvocation only works in Microsoft hosts, like the original shell or ISE.
MyInvocation only works in Microsoft hosts, like the original shell or ISE.
Alexander Riedel
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.