Results 1 to 2 of 2

Thread: Registry.SetValue question

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2018
    Posts
    1

    Registry.SetValue question

    Hello.

    I have a question why this code first runs from current location, when i restart the computer the second time it runs from system32.
    Code:
    Dim dataDirectory As String = String.Format("""{0}\musicbox.exe""", Environment.CurrentDirectory)
            Console.WriteLine(dataDirectory)
            Registry.SetValue("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run", "musicbox.exe", dataDirectory, RegistryValueKind.String)

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,929

    Re: Registry.SetValue question

    Welcome to VBForums

    Environment.CurrentDirectory returns the current working directory... but that is something that can change, even while your program is running.

    I suspect you actually want Application.StartupPath, which contains the path that your executable file is in.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width