open explorer with path

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.
Post Reply
User avatar
Domtar
Posts: 103
Last visit: Mon Sep 19, 2022 8:04 am
Has voted: 1 time

open explorer with path

Post by Domtar »

hi all,

here's the situation:

I'm writing a GUI to help the service desk in their daily tasks. For that purpose, I need to open an explorer window on a given path on a target computer. If I use invoke-item on the path, the user needs to enter his/her credentials each time they access a new computer, which I'm trying to get rid of.

It looks like this would fix the creds issue:

$creds = get-credential
new-psdrive -psprovider filesystem -name myPSDrive -root \\computer_name\c$\path_needed
invoke explorer here <<<--- not working as needed
remove-psdrive -name myPSDrive

But then, I am unable to open a windows explorer on that given path. Whenever I open explorer, I'm at the default path of it, not the path that I wish to display.

How can I do what I need?

Sorry if this is not clear enough.

Thanks
User avatar
owinsloe
Posts: 127
Last visit: Mon Sep 26, 2022 5:56 pm

Re: open explorer with path

Post by owinsloe »

You don't need all that,
try
&explorer <path>
eg
&explorer c:\temp
jvierra
Posts: 15288
Last visit: Wed Sep 28, 2022 2:31 pm
Answers: 26
Has voted: 4 times
Been upvoted: 28 times

Re: open explorer with path

Post by jvierra »

Domtar wrote: Fri Sep 16, 2022 6:04 am hi all,

here's the situation:

I'm writing a GUI to help the service desk in their daily tasks. For that purpose, I need to open an explorer window on a given path on a target computer. If I use invoke-item on the path, the user needs to enter his/her credentials each time they access a new computer, which I'm trying to get rid of.

It looks like this would fix the creds issue:

$creds = get-credential
new-psdrive -psprovider filesystem -name myPSDrive -root \\computer_name\c$\path_needed
invoke explorer here <<<--- not working as needed
remove-psdrive -name myPSDrive

But then, I am unable to open a windows explorer on that given path. Whenever I open explorer, I'm at the default path of it, not the path that I wish to display.

How can I do what I need?

Sorry if this is not clear enough.

Thanks
That will happen if you don't have permission on the path or some part of the path.

Why are you creating a "cred" object? Maybe you copied that line by mistake?
Post Reply