How do you run without a CMD window?

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 9 years and 6 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
mqh77777
Posts: 252
Last visit: Mon Feb 26, 2024 10:07 am
Has voted: 1 time

How do you run without a CMD window?

Post by mqh77777 »

I created a new Project. I created this on a Windows 7 x64 workstation but when I did a "build" I built it for PS 2.0 and x86. all of our Windows 7 workstations are running PS 2.0 on a 32-bit OS.

when I run the compiled .EXE it pops up my GUI but it also pops up a CMD window. We don't want that. I want it to be 100% GUI.


How do I make this run without a CMD window?
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: How do you run without a CMD window?

Post by davidc »

I moved this to the product forum since it isn't a scripting question.

When making your packaged executable, select the following engine:

SAPIEN PowerShell V2 Host (Windows Forms) Win32

David
David
SAPIEN Technologies, Inc.
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: How do you run without a CMD window?

Post by davidc »

Both Windows and Windows Form engines will hide the console window. The difference between the two is that the Forms engine suppresses all output and the Windows engine pops up message boxes for output.

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

Re: How do you run without a CMD window?

Post by mqh77777 »

ok, I click on the Deploy Tab\Build. From there I have a Script Packager options window. Under PLATFORM I do NOT have any executable options. I only have (command line) & (Windows forms)

so I picked (Sapien PowerShell v2 Host (Windows Forms) Win32. Now when I run my tool it does not complete. It should prompt me for "computer name" and "message to send" I only see the first prompt, not the second so my NetSend message never runs.

Do I have the right version of this tool? or am I missing functionality?
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: How do you run without a CMD window?

Post by davidc »

What are you using to prompt the users? This really depends on what you are doing in your script.

When using a GUI I recommend incorporating the input into the form or create a separate form to handle the input.

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

Re: How do you run without a CMD window?

Post by mqh77777 »

I have created 1 form. On this form I have 2 buttons. Here is the exact code for each button.

$buttonSendMSGTo1Computer_Click={
#TODO: Place custom script here
$computer = Read-Host -Prompt "Enter a single computer name"
$Message = Read-Host -Prompt "Enter your message here"
msg /SERVER:$computer * /TIME:200 $Message
}




$buttonSendMSGToAllComputer_Click={
#TODO: Place custom script here
import-module activedirectory
$Message = Read-Host -Prompt "Enter your message here"
New-Item -ItemType directory -Path "C:\Temp"
(Get-ADComputer -Filter * -SearchBase "ou=mgh_workstations,dc=acmel,dc=org").Name | Out-File c:\temp\allWin7.txt
$pc = Get-Content "c:\Temp\allWin7.txt"
foreach ($desktop in $pc)
{
msg /SERVER:$desktop * /TIME:2000 $Message

}
remove-item "c:\Temp\allWin7.txt"
}


So each button when pressed launches a new pop-up window that you enter text into. When I compile this into an .EXE and run it the pop-up is Not in the form of a GUI but it launches a .CMD window to ask me the computer name/message.
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: How do you run without a CMD window?

Post by davidc »

As I mentioned you are better off using your own custom GUI instead of relying on Read-Host.

The Window Forms engine isn't meant to be used for Host output or input. Try using the Windows engine instead of the Forms engine and see if that makes a difference.

I recommend reading this article:

http://www.sapien.com/blog/2012/06/04/u ... istrators/


David
David
SAPIEN Technologies, Inc.
This topic is 9 years and 6 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.