Saturday 15 August 2015

An issue with reading DB when program runs at startup in vb.net -


I'm new here and for vb.net and i think that i think it should be simple to do . I let the user decide to set up my program to decide if he wants to run the program on windows start up, it really works fine because this registration value is specifying the current machine instead of the local machine because the administration Need to bypass rights. However, when I restart my computer the program is like normal, but it does not read my access db which is located in the same folder as the program; It's an attempt to read DB from Windows \ System32

There is a way to force it to read from executablepath instead of System32

Here's my simple code.? :

  Private sub startup () if cbStartup.Checked = true My.Computer.Registry.CurrentUser.OpenSubKey ("Software"). OpenSubKey ("Microsoft"). OpenSubKey ("Windows"). OpenSubKey ("CurrentVersion"). OpenSubKey ("run", this is true). SetsValue ("CC_List", System.Windows.Forms.Application.ExecutablePath) otherwiseif cbStartup.Checked = false then My.Computer.Registry. CurrentUser.OpenSubKey ("Software"). OpenSubKey ("Microsoft"). OpenSubKey ("Windows"). OpenSubKey ("CurrentVersion"). OpenSubKey ("Run" is true) .DeleteValue ("CC_List", false) end if end o / s  current directory     
% windir% \ system32 .

You need to explicitly adjust all of your existing paths, which clearly Application.Ex ecutablePath , or put

 < Code> My.Computer.FileSystem.CurrentDirectory = My.Application.Info.DirectoryPath   

At the beginning of your program (which is the modern version of ChDir ... ).

No comments:

Post a Comment