Results 1 to 11 of 11

Thread: detect first run of my program on any pc[RESOLVED]

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2005
    Posts
    305

    Resolved detect first run of my program on any pc[RESOLVED]

    hiiiiii guys......
    i want to know how to detect first run of my program on a new comp ie wen my prog is installed and run for the first time it should display a welcome msg and den from the next runs it shuld nt come on dat pc...... hope u understood my problem.......
    thanks very much waiting for a reply
    Last edited by developerno1; Jul 10th, 2008 at 08:26 AM. Reason: problem solved

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: detect first run of my program on any pc

    You would need to write something off to the folder where the program was installed, or the registry, or something along those lines.

    Each time your program ran, it would check for this. If it was found, then it would know it had already been run, and would not show the welcome. If it did not find it, it would know it had not been run on the machine before, and would show the welcome.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2005
    Posts
    305

    Re: detect first run of my program on any pc

    ya i was also thinking on similar lines but i could not figur out which way wud be easy and how to implement in code, can anyone help plzzzzz

  4. #4
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Re: detect first run of my program on any pc

    Brother, I think I have an idea. Try the below one...
    vb Code:
    1. Dim Status As String
    2. Open App.Path & "\settings.txt" For Input As #1
    3. Input #1, Status
    4. Close #1
    5. If Status = "new" Then
    6.     MsgBox "Welcome to my program..!"
    7.     Open App.Path & "\settings.txt" For Output As #1
    8.     Print #1, "no"
    9.     Close #1
    10. End If
    Write the above code in the main form's load event... This will sove your problem...
    Please note that, you have to create a Text file named "Settings.txt" and type "new" inside. And include this file with your program... Thus it works...

    I hope this will help you...
    If you found this useful, please rate me........

  5. #5
    PowerPoster Ellis Dee's Avatar
    Join Date
    Mar 2007
    Location
    New England
    Posts
    3,530

    Re: detect first run of my program on any pc

    You should never write anything to the App.Path, since that is typically going to be under Program Files. This is considered a bad practice under XP, and it flat-out won't work under Vista.

    Instead, use the registry. If you want to conform to Windows standards, create a registry key for your program as follows:

    HKEY_CURRENT_USER\Software\<YourCompany>\<YourProgram>

    Then for this particular purpose you'd create a value called something like ShowWelcome or FirstRun.

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2005
    Posts
    305

    Thumbs up Re: detect first run of my program on any pc

    thanks guys problem solved...... thank u vry much 4 prompt replies

  7. #7
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Re: detect first run of my program on any pc

    Quote Originally Posted by Ellis Dee
    You should never write anything to the App.Path, since that is typically going to be under Program Files. This is considered a bad practice under XP, and it flat-out won't work under Vista.

    Instead, use the registry. If you want to conform to Windows standards, create a registry key for your program as follows:

    HKEY_CURRENT_USER\Software\<YourCompany>\<YourProgram>

    Then for this particular purpose you'd create a value called something like ShowWelcome or FirstRun.
    Are you saying that the above code doesn't work on XP or Vista...?
    I checked it in an XP machine and it worked.. But I dont know whether it works on a Vista machine.. I think to make programs for Vista machines, some changes need to be made for VB programs... I think someone had posted a thread here on 'how to create VB programs for Vista'...

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

    Re: detect first run of my program on any pc[RESOLVED]

    It won't work in Vista - and will only work in XP/2000 if you log in as an admin/power user (so not a limited user, as many people do, especially in an office).

    The thread you were thinking of is in our Classic VB FAQs (in the FAQ forum, which is shown near the top of our home page)

  9. #9
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: detect first run of my program on any pc[RESOLVED]

    Potentially, there is a problem with the registry as well.

    Many of our clients are now rolling out machines to their employees with the registry locked down.

    Because of this, we moved the target for any and all of the settings our software uses to a specific DB table.

    Although we didn't know it at the time, this has also positioned us pretty well, with respect to this issue anyway, for moving to Vista.

  10. #10
    PowerPoster Ellis Dee's Avatar
    Join Date
    Mar 2007
    Location
    New England
    Posts
    3,530

    Re: detect first run of my program on any pc[RESOLVED]

    That's an excellent point. If I wanted to store user settings in an environment with a locked-down registry, I'd save to a file (ini, database, whatever) in the user's Application Data folder under the same Company\Program tree structure as the registry uses.

    It's one of the few areas you can be guaranteed won't be locked down, and also isn't in plain sight of the user.

  11. #11
    Member
    Join Date
    Jul 2008
    Posts
    36

    Re: detect first run of my program on any pc[RESOLVED]

    I always write stuff to the \Documents and Settings\Username\Application Data

    or if, during install, they chose "All Users" then \Documents and Settings\All Users\

    I use the SHGetSpecialFolder API to get the path

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