Results 1 to 8 of 8

Thread: Better method than My.Settings?

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2006
    Posts
    615

    Better method than My.Settings?

    So I've created a program that sets settings using the My.Settings method. Once compiled and ran, it works smoothly.

    However, I seem to be running into an issue when I rename the executable or move it to another path. The settings get defaulted on the new executable because I'm assuming that the application thinks its a new file, when theoretically it's the same program just renamed or in a different location.

    Does anyone here have a good way to implement settings that stay with the program no matter if it is renamed or moved? I'm thinking about creating an ini file but I want to see what are some other people's methods and ideas on this.

    Thanks!
    If ive helped, RATE my post.

    If your thread is solved, and you got your answer, mark this thread Resolved.

    There is no other forum like VBFORUMS.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Better method than My.Settings?

    What you do is up to you but I can't conceive of a universe in which renaming an installed application would be a good idea. Basically, you will need something that stores the data in the same folder as the application and just uses a relative location find it. The problem with that is that, if you install the application properly then there may be some users who don't have write access to that folder. That's exactly why My.Settings stores its read/write data in each user's own folder, which they are guaranteed to have write access to. It's also important to remember that My.Settings stores a separate set of settings for each Windows user, which may not be a big deal for many people but is critical on many multi-user systems.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3
    New Member
    Join Date
    Mar 2014
    Location
    Internet NetWork
    Posts
    8

    Re: Better method than My.Settings?

    Check Path ..
    What u writed in path !!
    Can u use "path" function to remember path in any camputer !!

    get code here !

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2006
    Posts
    615

    Re: Better method than My.Settings?

    Quote Originally Posted by a_almisery View Post
    Check Path ..
    What u writed in path !!
    Can u use "path" function to remember path in any camputer !!

    get code here !
    Please don't spam my thread.

    Quote Originally Posted by jmcilhinney View Post
    What you do is up to you but I can't conceive of a universe in which renaming an installed application would be a good idea. Basically, you will need something that stores the data in the same folder as the application and just uses a relative location find it. The problem with that is that, if you install the application properly then there may be some users who don't have write access to that folder. That's exactly why My.Settings stores its read/write data in each user's own folder, which they are guaranteed to have write access to. It's also important to remember that My.Settings stores a separate set of settings for each Windows user, which may not be a big deal for many people but is critical on many multi-user systems.
    I'm making it so the user cant try to reset the settings by renaming the application. If the user figures out that they can rename the application to change settings which restrict the application, then they will have unlimited access to it. What gives them limited access is the data in the My.Settings, but it's useless if they can manipulate it to change reset the restrictions.
    If ive helped, RATE my post.

    If your thread is solved, and you got your answer, mark this thread Resolved.

    There is no other forum like VBFORUMS.

  5. #5
    Addicted Member
    Join Date
    Dec 2013
    Location
    Earth
    Posts
    230

    Re: Better method than My.Settings?

    Could you save as a text file? Each line is a setting?

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2006
    Posts
    615

    Re: Better method than My.Settings?

    Quote Originally Posted by NinjaNic View Post
    Could you save as a text file? Each line is a setting?
    That's what I was thinking with an INI file and some encryption. Figured someone might have a better idea than me though lol.
    If ive helped, RATE my post.

    If your thread is solved, and you got your answer, mark this thread Resolved.

    There is no other forum like VBFORUMS.

  7. #7
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Better method than My.Settings?

    Quote Originally Posted by GRPsuper9 View Post
    I'm making it so the user cant try to reset the settings by renaming the application. If the user figures out that they can rename the application to change settings which restrict the application, then they will have unlimited access to it. What gives them limited access is the data in the My.Settings, but it's useless if they can manipulate it to change reset the restrictions.
    You could probably write the app so that it won't run if it doesn't have the expected file name. You could even extend that to require a specific path, e.g.
    vb.net Code:
    1. Namespace My
    2.  
    3.     ' The following events are available for MyApplication:
    4.     '
    5.     ' Startup: Raised when the application starts, before the startup form is created.
    6.     ' Shutdown: Raised after all application forms are closed.  This event is not raised if the application terminates abnormally.
    7.     ' UnhandledException: Raised if the application encounters an unhandled exception.
    8.     ' StartupNextInstance: Raised when launching a single-instance application and the application is already active.
    9.     ' NetworkAvailabilityChanged: Raised when the network connection is connected or disconnected.
    10.     Partial Friend Class MyApplication
    11.  
    12.         Private Sub MyApplication_Startup(sender As Object, e As ApplicationServices.StartupEventArgs) Handles Me.Startup
    13.             If Windows.Forms.Application.ExecutablePath <> Computer.FileSystem.CombinePath(Computer.FileSystem.SpecialDirectories.ProgramFiles, "MyApplication\MyApplication.exe") Then
    14.                 MessageBox.Show("This application has not been run from the expected location and will be closed.")
    15.                 e.Cancel = True
    16.             End If
    17.         End Sub
    18.  
    19.     End Class
    20.  
    21.  
    22. End Namespace
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  8. #8

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2006
    Posts
    615

    Re: Better method than My.Settings?

    Quote Originally Posted by jmcilhinney View Post
    You could probably write the app so that it won't run if it doesn't have the expected file name. You could even extend that to require a specific path, e.g.
    vb.net Code:
    1. Namespace My
    2.  
    3.     ' The following events are available for MyApplication:
    4.     '
    5.     ' Startup: Raised when the application starts, before the startup form is created.
    6.     ' Shutdown: Raised after all application forms are closed.  This event is not raised if the application terminates abnormally.
    7.     ' UnhandledException: Raised if the application encounters an unhandled exception.
    8.     ' StartupNextInstance: Raised when launching a single-instance application and the application is already active.
    9.     ' NetworkAvailabilityChanged: Raised when the network connection is connected or disconnected.
    10.     Partial Friend Class MyApplication
    11.  
    12.         Private Sub MyApplication_Startup(sender As Object, e As ApplicationServices.StartupEventArgs) Handles Me.Startup
    13.             If Windows.Forms.Application.ExecutablePath <> Computer.FileSystem.CombinePath(Computer.FileSystem.SpecialDirectories.ProgramFiles, "MyApplication\MyApplication.exe") Then
    14.                 MessageBox.Show("This application has not been run from the expected location and will be closed.")
    15.                 e.Cancel = True
    16.             End If
    17.         End Sub
    18.  
    19.     End Class
    20.  
    21.  
    22. End Namespace
    I like that idea. I'm pretty sure this is the method I'm going to use unless someone has a better idea. Thanks, jmcilhinney!
    If ive helped, RATE my post.

    If your thread is solved, and you got your answer, mark this thread Resolved.

    There is no other forum like VBFORUMS.

Tags for this Thread

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