none
Different Path to the auto startup folder?

    Question

  • Hey guys this probebly is a very simple question but I'm making a program so users can easily add and remove program to the auto startup folder (programs in that folder will automaticly launch when windows is started up.) 

    And I'm displaying the programs in a listview.

    The code I'm using  to acces the startup folder in my program>>>

     Dim strtfldr As String = "C:\Users\Chris\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup"

    I think the chance is pretty big this code won't work on other people's pc. Because of    >>>>>>>         Users\Chris         <<<<<

    So is there another path to acces the folder so people won't get this problem?

    Thanks in advanced,

    Chris

    Tuesday, April 30, 2013 10:17 AM

Answers

  • Hi,

     Try replacing this line at the top of the program

        Dim strtfldr As String = "C:\Users\Chris\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup"
    

    with this line.

    Dim strtfldr As String = Environment.GetFolderPath(Environment.SpecialFolder.Startup)

    It will get the startup folder path of whoever is loged on and using the program.

    • Proposed as answer by Renee Culver Tuesday, April 30, 2013 12:00 PM
    • Marked as answer by Chrisy781 Tuesday, April 30, 2013 1:20 PM
    Tuesday, April 30, 2013 11:33 AM

All replies

  • See here for information on how to get to special folders.  StartMenu is included.

    http://msdn.microsoft.com/en-us/library/system.environment.specialfolder.aspx

    Your other problem is likely to be getting write access to that folder.

    • Proposed as answer by Blackwood Tuesday, April 30, 2013 11:57 AM
    Tuesday, April 30, 2013 10:34 AM
  • Thanks Acamar for your help, writing in the folder works fine.

    But I can you or somebody else give me an awnser, by giving me a path to the auto startup folder so this folder won't only be shown for people with a user called Chris.

    Tuesday, April 30, 2013 10:41 AM
  • Hi,

     Try replacing this line at the top of the program

        Dim strtfldr As String = "C:\Users\Chris\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup"
    

    with this line.

    Dim strtfldr As String = Environment.GetFolderPath(Environment.SpecialFolder.Startup)

    It will get the startup folder path of whoever is loged on and using the program.

    • Proposed as answer by Renee Culver Tuesday, April 30, 2013 12:00 PM
    • Marked as answer by Chrisy781 Tuesday, April 30, 2013 1:20 PM
    Tuesday, April 30, 2013 11:33 AM
  • This folder blewup with an "unexpected error" when I tried to check Acamars answer as a proposed answer.

    Renee


    "MODERN PROGRAMMING is deficient in elementary ways BECAUSE of problems INTRODUCED by MODERN PROGRAMMING." Me


    Tuesday, April 30, 2013 12:03 PM
  • The special folders enumeration I linked to provides you with the folders that you need to get to the users startup folder.   You do not need to use a string literal with the user name - use the appropriate enumerated value.  For instance, where you might use

    C:\Users\Chris\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup

    for user Chris for WIndows 7 installed on the C: drive in the Windows folder, you can use

    Environment.GetFolderPath(Environment.SpecialFolder.StartUp)

    for the current user for the current operating system installed at any location.

    • Edited by Acamar Tuesday, April 30, 2013 12:41 PM sp
    Tuesday, April 30, 2013 12:40 PM
  • Thanks IronRazerz again and Renee Culver & Acamar  for helping me out!

    Tuesday, April 30, 2013 1:23 PM