Open explorer.exe with different credentials

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 2 years and 7 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
MdAMdA
Posts: 8
Last visit: Thu Oct 07, 2021 4:35 am

Open explorer.exe with different credentials

Post by MdAMdA »

Product, version and build: Powershell Studio 2021 5.8.188
Operating system: Windows 2019
PowerShell version(s): 6




I use a GUI which starts with a runas account.
I have a button that calls explorer.exe. I have already tried a variety of ways, however the explorer does not open.

I have already tested the following alternatives:

(PopUp: I have a function that opens a message window)

Code: Select all

$Button_Click = {
	try
	{
		ii c:\Windows\explorer.exe "\\Server\Share$\"
	}
	catch
	{
		PopUp -Text "$($_.Exception.Message) `r`n $($_.Exception.ItemName) " -Titel "Warning"
	}

Code: Select all

$OpenFileDialog = New-Object System.Windows.Forms.FolderBrowserDialog
$OpenFileDialog.SelectedPath = "\\Server\Share$\"
$OpenFileDialog.ShowDialog() | Out-Null

Code: Select all

net use  "\\Server\Share$\"
explorer.exe  "\\Server\Share$\"

Code: Select all

$startinfo = new-object System.Diagnostics.ProcessStartInfo
$startinfo.FileName = "explorer.exe"
$startinfo.WorkingDirectory = "\\Server\Share$\"
[System.Diagnostics.Process]::Start($startinfo)
With all alternatives the explorer.exe appears in the taskManager, but no explorer window opens. I therefore think that it is related to the RunAs account and therefore the process cannot open Explorer in the user context.

As a solution I thought: Hey just start the explorer under the currently logged in user.
But then I found the article below: viewtopic.php?t=8868 .

Is there any way to implement this?
MdAMdA
Posts: 8
Last visit: Thu Oct 07, 2021 4:35 am

Re: Open explorer.exe with different credentials

Post by MdAMdA »

Sorry, I accidentally opened the question in the wrong forum. Can this please be moved to the PowershellStudio forum.
User avatar
Alexander Riedel
Posts: 8478
Last visit: Tue Mar 26, 2024 8:52 am
Answers: 19
Been upvoted: 37 times

Re: Open explorer.exe with different credentials

Post by Alexander Riedel »

[Topic moved by moderator]
Alexander Riedel
SAPIEN Technologies, Inc.
tlcoffee
Posts: 1
Last visit: Tue Aug 01, 2023 2:48 am

Re: Open explorer.exe with different credentials

Post by tlcoffee »

How about:

Start-Process explorer.exe "Path"
MdAMdA
Posts: 8
Last visit: Thu Oct 07, 2021 4:35 am

Re: Open explorer.exe with different credentials

Post by MdAMdA »

Sorry, no that doesn't work either. The explorer is started, the process appears in the task manager. But the explorer window does not focus in the foreground and you cannot switch to it.

Started in Powershell Studio, all solutions work. But with the GUI, started with a runas account no explorer window opens.
User avatar
localpct
Posts: 397
Last visit: Thu Oct 27, 2022 5:57 am

Re: Open explorer.exe with different credentials

Post by localpct »

I think this has something to do with UAC. I have ran into similar issues
Might also be my corporate policy & so I dropped it
MdAMdA
Posts: 8
Last visit: Thu Oct 07, 2021 4:35 am

Re: Open explorer.exe with different credentials

Post by MdAMdA »

No, even with UAC turned off, no Explorer window opens.

also here: the Explorer.exe appears in the task manager with a size of about 1,600 KB, but it does not open.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Open explorer.exe with different credentials

Post by jvierra »

Explorer cannot be run twice in a session under two sets of credentials. The two session will be merged under the visible sessions credentials.
MdAMdA
Posts: 8
Last visit: Thu Oct 07, 2021 4:35 am

Re: Open explorer.exe with different credentials

Post by MdAMdA »

jvierra wrote: Wed Aug 25, 2021 7:48 am Explorer cannot be run twice in a session under two sets of credentials. The two session will be merged under the visible sessions credentials.
Is there any way around this and open a new Explorer Session?
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Open explorer.exe with different credentials

Post by jvierra »

If you can help me get blood from a stone thenmaybe we can figure out how to crack Windowws security restrictions and run against the wind.
This topic is 2 years and 7 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