tags:

views:

44

answers:

3

How do i get the startup folder path for "Current user" and "All user" in VB.net?

A: 

If you mean the Start \ All Programmes \ Startup folder, you can use environment varibles

eg All users in DOS

echo %ALLUSERSPROFILE%\Start Menu\Programs\Startup\

eg Current user in DOS

echo %USERPROFILE%\Start Menu\Programs\Startup\
Rudu
A: 

Try

 Environment.GetEnvironmentVariable("ALLUSERSPROFILE")  'All Users Directory'
 Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)) 'Current User Directory'

With the Environment.SpecialFolder enumeration you also have available a Startup and a CommonStartup enumeration. They map to the current user and the all users startup directory.

Mark Hall
How to i get to "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup" in my program.
jameslcs
Environment.GetFolderPath(Environment.SpecialFolder.CommonStartup) This will give you the path you want
Mark Hall
thanks that what i needed.
jameslcs
i found out that Environment.GetFolderPath(Environment.SpecialFolder.CommonStartup) is only can be use in .net 4, is there a way to get the path "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup" for .net 3.5 or lower? thanks.
jameslcs
Mark Hall
thanks Mark, i will give it a try.
jameslcs
A: 

Im unclear about exatly what location you want ill give you a wey to get Environment Variables.

Private Function GetEnvironmentVariable(ByVal var As String) As String
    var = Environment.GetEnvironmentVariable(var)
    Return var
End Function

Then pass it the name of the Environment Variable you want. If you are going to add more to the paths like in Rudu's post, you should keep in mind that paths are different of different operating systems.

giodamelio