Windows 10

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 6 years and 8 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
v35678
Posts: 23
Last visit: Fri Jan 05, 2024 8:25 am

Windows 10

Post by v35678 »

Hi, I'm having issues when running some GUIs on Windows 10. Whenever I use $global:cred = Get-Credential -Credential it will not pass the credentials on. Works great in Windows 7. Also If I use the RunAs user or Impersonate user (Script Packager) I get the working directory is invalid message when running the EXE. Any ideas. Thanks for any help in advance.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Windows 10

Post by jvierra »

What do you mean by it won't pass the credentials on?

I use this on Win 10 with no issues.
User avatar
Alexander Riedel
Posts: 8479
Last visit: Thu Mar 28, 2024 9:29 am
Answers: 19
Been upvoted: 37 times

Re: Windows 10

Post by Alexander Riedel »

"Also If I use the RunAs user or Impersonate user (Script Packager) I get the working directory is invalid message when running the EXE"

Most likely you run the exe from a personal user folder that either does not exists or is not accessible for the other user.
Alexander Riedel
SAPIEN Technologies, Inc.
User avatar
v35678
Posts: 23
Last visit: Fri Jan 05, 2024 8:25 am

Re: Windows 10

Post by v35678 »

Alexander, thanks for the tip. Yes it was in a personal folder. It seems to work now.

jvierra when I use $global:cred = Get-Credential -Credential it brings up the credential login box but when I use the credentials for example

Start-Process "C:\Program Files\Desktop\DesktopPowershellAPPS\RADIA 91 Console.exe" -Credential $cred it will not launch the RADIA 91 Console.exe
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Windows 10

Post by jvierra »

v35678 wrote:Alexander, thanks for the tip. Yes it was in a personal folder. It seems to work now.

jvierra when I use $global:cred = Get-Credential -Credential it brings up the credential login box but when I use the credentials for example

Start-Process "C:\Program Files\Desktop\DesktopPowershellAPPS\RADIA 91 Console.exe" -Credential $cred it will not launch the RADIA 91 Console.exe
This is normal behavior. To be prompted for creds on a command don't use the variable or use a null variable. If the variable is already set it will not prompt. You are setting that variable globally so it will override the prompt.
User avatar
v35678
Posts: 23
Last visit: Fri Jan 05, 2024 8:25 am

Re: Windows 10

Post by v35678 »

Hi, I apologize if I’m misunderstanding or not explaining this right so here is exactly what is happening. We have a menu PowerShell gui that allows us to launch certain applications with elevated Administrative rights. The first button is the set credentials which brings up the PowerShell credential request login screen. The code is this:
$buttonSetCredentials_Click={
	#TODO: Place custom script here
	$global:cred = Get-Credential -Credential 'Dom1\'
}
We login using our Admin account.

The other buttons allow us to launch the apps with the credentials we just set. For example:
$buttonRadiaConsoleSC_Click={
	#TODO: Place custom script here
	Start-Process "C:\Program Files\Desktop\DesktopPowershellAPPS\RADIA 91 Console.exe" -Credential $cred
}
$buttonComputerSupportSC_Click={
	#TODO: Place custom script here
	Start-Process "C:\Program Files\Desktop\DesktopPowershellAPPS\SDSA.exe" -Credential $cred
}
This works perfectly in Windows 7. In Windows 10 we can set the credentials but when we click on a button to launch the apps it doesn’t do anything. If we go to the folder of the apps and “run as a different user” in Windows 10 it works. We really need it to act the same way in windows 10 as it does in Windows 7. Please note I’m fairly new to powershell so if there is a different way to accomplish this that would be awesome.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Windows 10

Post by jvierra »

What does "it doesn’t do anything" mean? If there is an issue with the credentials you will get an error. Have you tried running this in the debugger to be sure your event is being called?
User avatar
v35678
Posts: 23
Last visit: Fri Jan 05, 2024 8:25 am

Re: Windows 10

Post by v35678 »

jvierra wrote:What does "it doesn’t do anything" mean? If there is an issue with the credentials you will get an error. Have you tried running this in the debugger to be sure your event is being called?
The apps do not launch like in Windows 7. There isn't an issue with the credentials. I will try the debugger to see if anything gets flagged.
User avatar
v35678
Posts: 23
Last visit: Fri Jan 05, 2024 8:25 am

Re: Windows 10

Post by v35678 »

After your suggestion with the debugging, with Windows 10 I get start-process: this command cannot be run due to the error: The requested operation requires elevation.

Start-Process "C:\Program Files\Desktop\DesktopPowershellAPPS\RADIA 91 Console.exe" -Credential $cred
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Windows 10

Post by jvierra »

YOU must run you script as an elevated administrator.
This topic is 6 years and 8 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