script works in ps1 but in psf

This forum can be browsed by the general public. Posting is limited to current SAPIEN license holders with active maintenance and does not offer a response time guarantee.
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.
This topic is 6 years and 3 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.
User avatar
abrtech
Posts: 6
Last visit: Fri Dec 03, 2021 11:05 am

script works in ps1 but in psf

Post by abrtech »

Hi,

I'm having trouble debugging these 3 lines of code as I do not get any errors, it just hangs. It is a custom written DLL.

This connects to another computer "A10" and sets some variables in an application on that system.

When I have this code in a ps1 file I get it to run successfully.

Add-Type -path "C:\ECM\Exams_ExamCenterManager\CFSocketConnection.dll"
$connected = [CFSocketConnection.ExamConnection]::GetConnection("A10").Result
$connected.setexamtime(30)

But the below does not work. Please let me know if I need to supply anything else.

$form1_Load={
Add-Type -path "C:\ECM\Exams_ExamCenterManager\CFSocketConnection.dll"
$connected = [CFSocketConnection.ExamConnection]::GetConnection("A10").Result
$connected.setexamtime(30)
}

The second line is where it hangs. ($connected = [CFSocketConnection.ExamConnection]::GetConnection("A10").Result)

PowerShell Studio 2017 v5.4.145
64 bit
Windows 10 64 bit
STA mode
Elevated Mode
User avatar
Alexander Riedel
Posts: 8478
Last visit: Tue Mar 26, 2024 8:52 am
Answers: 19
Been upvoted: 37 times

Re: script works in ps1 but in psf

Post by Alexander Riedel »

Sounds like a network timeout. You probably need to make a firewall exception.
Alexander Riedel
SAPIEN Technologies, Inc.
User avatar
abrtech
Posts: 6
Last visit: Fri Dec 03, 2021 11:05 am

Re: script works in ps1 but in psf

Post by abrtech »

Thank you for the reply. It works if I run it as a ps1 so I don't think it is a firewall issue. However I disabled both firewalls and I still have the same result.

I have also tried localhost with the same results. Works in ps1 script but not on form.
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: script works in ps1 but in psf

Post by davidc »

This could have to do with the way the command works internally. Since the GUI is holding up the pipeline, it is possible that some events aren't triggered that the command relies on.

Try running the command via a Job using the Button - Start Job control set and see if that works for you.

https://info.sapien.com/index.php/guis/ ... sive-forms
David
SAPIEN Technologies, Inc.
User avatar
abrtech
Posts: 6
Last visit: Fri Dec 03, 2021 11:05 am

Re: script works in ps1 but in psf

Post by abrtech »

Thanks, it works!
This topic is 6 years and 3 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.