-
Feb 23rd, 2015, 11:12 PM
#1
Thread Starter
Fanatic Member
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.
-
Feb 23rd, 2015, 11:26 PM
#2
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.
-
Feb 23rd, 2015, 11:29 PM
#3
New Member
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 !
-
Feb 23rd, 2015, 11:56 PM
#4
Thread Starter
Fanatic Member
Re: Better method than My.Settings?
Originally Posted by a_almisery
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.
Originally Posted by jmcilhinney
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.
-
Feb 24th, 2015, 12:08 AM
#5
Addicted Member
Re: Better method than My.Settings?
Could you save as a text file? Each line is a setting?
-
Feb 24th, 2015, 12:13 AM
#6
Thread Starter
Fanatic Member
Re: Better method than My.Settings?
Originally Posted by NinjaNic
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.
-
Feb 24th, 2015, 12:25 AM
#7
Re: Better method than My.Settings?
Originally Posted by GRPsuper9
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:
Namespace My ' The following events are available for MyApplication: ' ' Startup: Raised when the application starts, before the startup form is created. ' Shutdown: Raised after all application forms are closed. This event is not raised if the application terminates abnormally. ' UnhandledException: Raised if the application encounters an unhandled exception. ' StartupNextInstance: Raised when launching a single-instance application and the application is already active. ' NetworkAvailabilityChanged: Raised when the network connection is connected or disconnected. Partial Friend Class MyApplication Private Sub MyApplication_Startup(sender As Object, e As ApplicationServices.StartupEventArgs) Handles Me.Startup If Windows.Forms.Application.ExecutablePath <> Computer.FileSystem.CombinePath(Computer.FileSystem.SpecialDirectories.ProgramFiles, "MyApplication\MyApplication.exe") Then MessageBox.Show("This application has not been run from the expected location and will be closed.") e.Cancel = True End If End Sub End Class End Namespace
-
Feb 24th, 2015, 12:34 AM
#8
Thread Starter
Fanatic Member
Re: Better method than My.Settings?
Originally Posted by jmcilhinney
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:
Namespace My ' The following events are available for MyApplication: ' ' Startup: Raised when the application starts, before the startup form is created. ' Shutdown: Raised after all application forms are closed. This event is not raised if the application terminates abnormally. ' UnhandledException: Raised if the application encounters an unhandled exception. ' StartupNextInstance: Raised when launching a single-instance application and the application is already active. ' NetworkAvailabilityChanged: Raised when the network connection is connected or disconnected. Partial Friend Class MyApplication Private Sub MyApplication_Startup(sender As Object, e As ApplicationServices.StartupEventArgs) Handles Me.Startup If Windows.Forms.Application.ExecutablePath <> Computer.FileSystem.CombinePath(Computer.FileSystem.SpecialDirectories.ProgramFiles, "MyApplication\MyApplication.exe") Then MessageBox.Show("This application has not been run from the expected location and will be closed.") e.Cancel = True End If End Sub End Class 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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|