Running *.ps1 from converted *.exe

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 7 years and 11 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
GHIsolierung
Posts: 62
Last visit: Tue Nov 02, 2021 12:46 am

Running *.ps1 from converted *.exe

Post by GHIsolierung »

Product, version and build:Powershell Studio 2015 V 4.2.91
32 or 64 bit version of product:64
Operating system: Windows 8.1
32 or 64 bit OS: 64

Hello,

I try to open another Powershell Script from converted *.exe ( Powershell Script to exe)

If I am in Powershell Studio and working from the Script, I open another Script with double dot
  1. function Get-MyCredentials
  2. {
  3. .  .\Credentials.ps1 -BackColor $BackColor  # this opens my own created credential window, that I use often.
  4.  
  5.  
  6.  
  7.     $Credenials = New-Object System.Management.Automation.PSCredential -ArgumentList $Username, $Password
  8.    
  9.     Return $Credentials
  10. }
and this works very well.
However if i convert my Powershell Application to an exe File, this does not work anymore.

How do I have to write the code in this case?

Greets and thanks in advance
User avatar
Alexander Riedel
Posts: 8479
Last visit: Thu Mar 28, 2024 9:29 am
Answers: 19
Been upvoted: 37 times

Re: Running *.ps1 from converted *.exe

Post by Alexander Riedel »

"this does not work anymore" can be anything. Can you provide some details? Error messages? What is the nature of your application? Command line? Windows Forms?
Alexander Riedel
SAPIEN Technologies, Inc.
User avatar
GHIsolierung
Posts: 62
Last visit: Tue Nov 02, 2021 12:46 am

Re: Running *.ps1 from converted *.exe

Post by GHIsolierung »

Hello and thanks for the reply.

The Multiform Scripts perpuse is to massive Reboot our Server at a scheduled time.


For this and for other scripts I wrote an own authentication form similar to Microsofts one, that I call whenever I need credentials.

Simple Thing, two textboxes returning username and Password.

This works fine if i call this 'credential.ps' from my scripts via < . . \credential.ps1 >.
If I convert my main Script to an exe File, the call for my credentials.ps Skript is ignored .
After that the sckript runs into a failure, cause no credentials are given.
I tried to convert to all kinds of Windows Forms ( 32,64, V2, V3, STA not STA etc)

The question is, how to call a Powershell Script from a converted executable.

If you need the full code, ist not a Problem, didnt want to bother you with 1500 Lines of code.
Greets and thanks in advance
. 2016-03-19 16.45.22.png
. 2016-03-19 16.45.22.png (4.33 KiB) Viewed 3518 times
Attachments
Massive Rebooter 2016-03-19 16.44.46.png
Massive Rebooter 2016-03-19 16.44.46.png (9.55 KiB) Viewed 3518 times
User avatar
GHIsolierung
Posts: 62
Last visit: Tue Nov 02, 2021 12:46 am

Re: Running *.ps1 from converted *.exe

Post by GHIsolierung »

...hm no one else has the Problem.

How do you open other skripts (or other exe) from converted powershell Skript?
User avatar
GHIsolierung
Posts: 62
Last visit: Tue Nov 02, 2021 12:46 am

[solved]Running *.ps1 from converted *.exe

Post by GHIsolierung »

ok solved it.

changed the code from < . .\Credentials.ps -BackColor $BackColor >
to
  1. function Get-MyCredentials
  2. {
  3.      $path = $ScriptDirectory + "\Credentials.ps1"
  4.     [b]& $path -Backcolor $BackColor[/b]
  5.    
  6.     $Creds = New-Object System.Management.Automation.PSCredential -ArgumentList $Username, $Password
  7.     Return $Creds
  8. }
And now it is working, even if I have converted my Skript to an executable
This topic is 7 years and 11 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.