This code does not run

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
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.
This topic is 9 years and 7 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.
Locked
User avatar
mqh77777
Posts: 252
Last visit: Mon Feb 26, 2024 10:07 am
Has voted: 1 time

This code does not run

Post by mqh77777 »

We have PowerShell Studio 2014. I have a basic dialog that has 1 button.

But before the dialog runs I have the following code:

$time1 = Get-Date -Format yyyyMMddhh
$time1


This code is followed by the default Sapien code that runs the Dialog and displays my 1 button.

My problem is this code does not execute and I do not see the output of $time1 in the OUTPUT window. now, if I run the same 2 lines of code in PowerShell ISE they work and I see the yyyymmddhh

How come I don't see any output in the Sapien OUTPUT window?
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: This code does not run

Post by davidc »

In a GUI Script objects will not "pipe out" because the pipeline is held up by the form's ShowDialog function. If you want to display text, you will need to directly use Write-Host.

But since are using a GUI, it is considered a best practice to display messages within the GUI itself instead of relying on the console.

David
David
SAPIEN Technologies, Inc.
User avatar
mqh77777
Posts: 252
Last visit: Mon Feb 26, 2024 10:07 am
Has voted: 1 time

Re: This code does not run

Post by mqh77777 »

Here is what I'm trying to do, please let me know if this tool will work.

I need to create an interactive tool that will read the current date/time. Then, compare that date/time to the last time the machine rebooted. If they are 1 week part prompt the user with a dialog that tells them to reboot. But this dialog will have several buttons.

(delay 2 hours)
(delay 4 hours)
(delay 6 hours)
(reboot now)

If any of the delay buttons are pressed when that time is up it will have a 15 min countdown to the reboot.

Am I using the right tool for this?
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: This code does not run

Post by jvierra »

What is the issue? What is not working?

Are you asking for someone to write this for you?
User avatar
mqh77777
Posts: 252
Last visit: Mon Feb 26, 2024 10:07 am
Has voted: 1 time

Re: This code does not run

Post by mqh77777 »

jvierra, I'd like to write this all myself, I guess I just need a few pointers. I'm new to this tool so can it do what I want it to? I don't want to invent a lot of time into writing this if the tool is not capable of doing what I need.

Thank you.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: This code does not run

Post by jvierra »

mqh777 wrote:jvierra, I'd like to write this all myself, I guess I just need a few pointers. I'm new to this tool so can it do what I want it to? I don't want to invent a lot of time into writing this if the tool is not capable of doing what I need.

Thank you.
What have you written so far? From your post it is not possible for me to understand what you are asking. Please post you code so I can try to understand.
This topic is 9 years and 7 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.
Locked