Commandline execution

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 SUBSCRIPTION NUMBERS, LICENSE 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.
User avatar
cmartin16
Posts: 3
Joined: Sun Mar 03, 2013 12:43 pm

Commandline execution

Post by cmartin16 » Mon Oct 07, 2019 8:47 am

I retired a couple of years ago and haven't used Powershell Studio since then. I recently took a temporary job and got a new version of Powershell Studio, but compiling scripts doesn't behave the way I remember.

If I compile a script using the "SAPIEN Powershell V5 Host (Command line)" Script Engine option, it will open a new console when I run it from a Powershell window and all output goes to that new console with no way to recover it without just looking at it.

If I simply open a folder browser and double-click on the executable, it opens a console, then opens a second console. The output is directed to this second console.

I found a video from this past July at https://www.youtube.com/watch?v=5khkPaSNAU4 where the demonstrator was using PrimalScript Editor to do the same thing, and it did not open the extra console. Output was passed back to the calling Powershell window.

So what am I missing? Has my memory slipped? Is there some setting I haven't checked, or is this just how Powershell Studio works now. Should I have gotten a copy of PrimalScript Editor instead?

User avatar
brittneyr
Site Admin
Posts: 187
Joined: Thu Jun 01, 2017 7:20 am

Re: Commandline execution

Post by brittneyr » Mon Oct 07, 2019 9:30 am

[Moved to the PowerShell Studio Product Forum by Moderator]

To help you better we need some information from you.

*** Please fill in the fields below. If you leave fields empty or specify 'latest' rather than the actual version your answer will be delayed as we will be forced to ask you for this information. ***

Product, version and build:
32 or 64 bit version of product:
Operating system:
32 or 64 bit OS:

*** Please add details and screenshots as needed below. ***
Brittney Ryn
SAPIEN Technologies, Inc.

User avatar
cmartin16
Posts: 3
Joined: Sun Mar 03, 2013 12:43 pm

Re: Commandline execution

Post by cmartin16 » Mon Oct 07, 2019 1:10 pm

Product: PowerShell Studio 2019 (64 Bit)
Build: v5.6.167
OS: Windows 10 Enterprise (64 Bit)
Build: v10.0.15063.0

User avatar
Alexander Riedel
Posts: 7049
Joined: Tue May 29, 2007 4:43 pm

Re: Commandline execution

Post by Alexander Riedel » Mon Oct 07, 2019 2:26 pm

Are you using RunAs in the packager settings to execute the script under different user credentials?
Alexander Riedel
SAPIEN Technologies, Inc.

User avatar
cmartin16
Posts: 3
Joined: Sun Mar 03, 2013 12:43 pm

Re: Commandline execution

Post by cmartin16 » Mon Oct 07, 2019 3:06 pm

Yes, this needs to be run with a service account.

User avatar
Alexander Riedel
Posts: 7049
Joined: Tue May 29, 2007 4:43 pm

Re: Commandline execution

Post by Alexander Riedel » Mon Oct 07, 2019 3:21 pm

Then this is expected behavior. The exe basically launches itself with the specified credentials. Since you cannot run a process as user B in a console that runs as user A, Windows creates a new console.
It *might* be possible for us to redirect the output back to the original console. I would have to investigate that.
Alexander Riedel
SAPIEN Technologies, Inc.