Make exe

Ask your PowerShell-related questions, including questions on cmdlet development!
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 7 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.
Locked
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Make exe

Post by jvierra »

Again - you cannot make a standard user an admin by running with alternate credentials. The user must have permission on the resource.
User avatar
stevens
Posts: 493
Last visit: Mon Sep 19, 2022 12:23 am
Has voted: 2 times

Re: Make exe

Post by stevens »

The exe only runs powershell commands to check the health of the local pc then generates a report. That doesn't work with standard user but DOES work when I run it under local admin.
However then the output in a textbox (f.e. checking cpu, checking memory etc) does not appear.

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

Re: Make exe

Post by jvierra »

Without a better example of your code there is no way to understand what you are asking or to be of much help.

Create a small project with the minimum amount of code needed to demonstrate your issue and attach it here.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Make exe

Post by jvierra »

There is a way to discover where the newly launched program is running but it cannot be done with native PowerShell. The Windows low level API has calls that can report on the "desktop" that the program is associated with or running on. This can be accessed by "C" code and possibly via a P/Invoke. I cannot tell off the top of my head what the API calls are.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Make exe

Post by jvierra »

Here is a list of API calls that can access the desktop session and report on its information. I have not tried it under PowerShell with alternate credentials. It may not work as the new process may have a separate session that is just sharing the display. Some testing would be necessary.
User avatar
stevens
Posts: 493
Last visit: Mon Sep 19, 2022 12:23 am
Has voted: 2 times

Re: Make exe

Post by stevens »

Here is my code, not fully deleted some stuff so the picture is clear:

https://www.dropbox.com/s/z7n3g0aasul78 ... m.zip?dl=0

I'd like to have the exe run without the need of local admin credentials or at least try to run and only if it doesn't work, run with specific credentials (it works with local admin but not when I use a domain user -with more rights-).

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

Re: Make exe

Post by jvierra »

Can you post your PSF or project as an attachment to this forum.

I also request that you create the smallest example of your issue. The forum is not really designed for detailed code analysis and debugging. Also, many time by simplifying your code you will discover your error on your own.
User avatar
stevens
Posts: 493
Last visit: Mon Sep 19, 2022 12:23 am
Has voted: 2 times

Re: Make exe

Post by stevens »

There is almost no code in the project. I don't see how I could make it any smaller.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Make exe

Post by jvierra »

The code you posted does not help us to understand your issue and cannot be run on any system but your systems so it is hard to try and figure out what you are asking.
User avatar
stevens
Posts: 493
Last visit: Mon Sep 19, 2022 12:23 am
Has voted: 2 times

Re: Make exe

Post by stevens »

According to me the code can run on any system and it shows exactly what my problem is.
Please tell me then how I could make it more clearly?
This topic is 7 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.
Locked