Opening a specific folder from VB

Darren Rose 281 Reputation points
2020-12-01T21:43:50.977+00:00

Hi

I am trying to open a specified folder location from VB

I am using Process.Start("C:\temp") as example and this works fine

But some of the paths I want to open won't work in same way

e.g. Process.Start("%WINDIR%\Installer")

gives "System.ComponentModel.Win32Exception: 'The system cannot find the file specified'"

Some other forum mentioned doing it like this Process.Start("explorer.exe", "%WINDIR%\Installer") but that just opens my Documents folder instead of specified path

It seems to be paths that have environment variables in e.g. %WINDIR% or %APPDATA% etc

Any thoughts please

VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,737 questions
0 comments No comments
{count} votes

Accepted answer
  1. Viorel 118K Reputation points
    2020-12-01T21:47:01.053+00:00

    Try this example:

    Process.Start(Environment.ExpandEnvironmentVariables("%WINDIR%\Installer"))
    
    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.