Results 1 to 13 of 13

Thread: make program autostart

  1. #1
    Guest
    I want my program to auto start on machine reboot (WIN95/98 VB6).
    I know I can manually add the .exe name to windows/all users/startmenu/programs/startup folder, but I want the program to install /check installed itself somehow. Maybe an API call?

  2. #2
    Guest
    you can either add a registry entry, or add a shortcut to the start up folder.

    you have to use API for either option.

  3. #3
    Guest
    ok, what API's do I need to
    check if shortcut exists, add one if not existing?
    (is s/cut's safer than delving into registry?)

  4. #4
    Lively Member
    Join Date
    May 1999
    Location
    Singapore
    Posts
    116
    for registry...you create an entry in
    HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run
    this is fopr running the app when user logs in...

    HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run
    this is for running when the computer starts up

    using the registry is better as the user won't be able to edit it as easily....

    YC Sim
    Teenage Programmer
    UIN 37903254



  5. #5
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    Yeah, but your users will hate you for putting it where it's hard to find. I know I would.
    Harry.

    "From one thing, know ten thousand things."

  6. #6
    Fanatic Member Dim's Avatar
    Join Date
    Jul 2000
    Posts
    620
    I belive it's this one
    Code:
    Public Declare Function RegCreateKeyEx Lib "advapi32.dll" Alias "RegCreateKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal Reserved As Long, ByVal lpClass As String, ByVal dwOptions As Long, ByVal samDesired As Long, lpSecurityAttributes As SECURITY_ATTRIBUTES, phkResult As Long, lpdwDisposition As Long) As Long
    
    'or
    
    Public Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
    
    
    Public Const REG_CREATED_NEW_KEY = &H1
    Then you would call it in the form_load of you appl.

    Hope that helped,
    D!m

    Dim

  7. #7
    Guest
    OK thanks, Now what happen to registry entry each time program starts? is the API call smart enought not to add a new entry each time?

    Also I agree that hiding it in the registry is hell for the end user/system maintenance...
    How can I put into startup folder with code ? (& check if exists if necessary)?

  8. #8
    Lively Member
    Join Date
    Jun 2000
    Location
    Belgium
    Posts
    77
    I don't remember where the startup folder in Win95/98 (i think it is \windows\startup\ without profile and \windows\profile\Start Menu\Programs\Startup with using profile)
    For WinNT, put your shortcut in the All Users startup folder(\WinNT\profiles\All Users\Start Menu\Programs\Startup)
    Becuase the shortcut is a file, you can easily check if it exist.
    KWell

  9. #9
    Guest
    thanks, but HOW do I write code to make the shortcut appear in the startup subdir?? (& check if already exists?)

  10. #10
    Lively Member
    Join Date
    May 1999
    Location
    Singapore
    Posts
    116
    use this to create a link in the startup folder of the current user

    Private Declare Function fCreateShellLink Lib "VB5STKIT.DLL" (ByVal lpstrFolderName As String, ByVal lpstrLinkName As String, ByVal lpstrLinkPath As String, ByVal lpstrLinkArgs As String) As Long
    Private Sub Form_Load()
    'Create a shell link on your desktop
    lngresult = fCreateShellLink("Startup", "LINK", "C:\myfile.exe", "")
    End Sub

    YC Sim
    Teenage Programmer
    UIN 37903254



  11. #11
    Guest
    thanks all
    I will try s/cut code out..

  12. #12
    New Member
    Join Date
    May 2000
    Posts
    13

    I still have a question!

    "fCreateShellLink" works well. But it can't add a shortcut to a general folder,such as "d:\". Anyone has better way?
    Very glad to see you !
    I'm a very begginer!

  13. #13
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538

    Talking creating shortcuts


    If you look on MSDN site for FileSystemObject object, it has a copyfile method/property which you could use for this

    It is not very professional I know, but when doing installs, I make some of my small programs install to one directory (user does not have a choice where it goes). For this instance, as I know where the program is, I create a shortcut to that location on my PC, then use this copyfile option to copy this shortcut to the C:☻windows☻startup folder, or as you mentioned D drive.

    Alex Read
    VB6 learning Edition

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