Skip to content

VBMAN.StartUp - Startup Management Object

Overview

VBMAN.StartUp provides Windows startup item management functionality, implemented through registry operations.

Core Features

  • Add/Remove Startup Items: One-click toggle startup status
  • Status Check: Check if specified program is set to startup
  • Flexible Path: Support string path or App object

Properties

PropertyTypeDescription
LastErrorStringLast error message

Methods

Has

Check if already set to startup

vb
Public Function Has(ByVal Name As String) As Boolean

Parameters:

  • Name - Startup item name

Returns: True=exists, False=does not exist

Example:

vb
If VBMAN.StartUp.Has("MyApplication") Then
    CheckBoxStartup.Value = vbChecked
Else
    CheckBoxStartup.Value = vbUnchecked
End If

Toggle

Toggle startup status

vb
Public Function Toggle(ByVal Name As String, ByRef Path As Variant, ParamArray StartArgs() As Variant) As Boolean

Parameters:

  • Name - Startup item name
  • Path - Program path (can be string or App object)
  • StartArgs - Startup parameters (optional, variable parameters)

Returns: True=operation successful, False=failure

Description: If startup item exists, delete it; if not exists, add it

Example:

vb
' Use string path
VBMAN.StartUp.Toggle "MyApp", "C:\Program Files\MyApp\app.exe"

' Use App object (recommended)
VBMAN.StartUp.Toggle "MyApplication", App

' With startup parameters
VBMAN.StartUp.Toggle "MyApp", App, "--minimized", "--auto-start"

Comprehensive Examples

Example 1: Startup Toggle Switch

vb
Private Sub CheckBoxStartup_Click()
    Dim success As Boolean
    
    If CheckBoxStartup.Value = vbChecked Then
        ' Add to startup
        success = VBMAN.StartUp.Toggle("MyApplication", App)
        If Not success Then
            MsgBox "Failed to set startup: " & VBMAN.StartUp.LastError
            CheckBoxStartup.Value = vbUnchecked
        End If
    Else
        ' Remove from startup
        success = VBMAN.StartUp.Toggle("MyApplication", App)
        If Not success Then
            MsgBox "Failed to cancel startup: " & VBMAN.StartUp.LastError
            CheckBoxStartup.Value = vbChecked
        End If
    End If
End Sub

Private Sub Form_Load()
    ' Check current startup status
    CheckBoxStartup.Value = IIf(VBMAN.StartUp.Has("MyApplication"), vbChecked, vbUnchecked)
End Sub

Example 2: Startup with Parameters

vb
Private Sub SetAutoStartWithParams()
    ' Set startup and pass parameters
    Dim success As Boolean
    success = VBMAN.StartUp.Toggle("MyApp", App, "--silent", "--tray")
    
    If success Then
        MsgBox "Startup set successfully!"
    Else
        MsgBox "Setup failed: " & VBMAN.StartUp.LastError
    End If
End Sub

Best Practices

  1. Use App Object: Recommend using App object instead of hardcoding path
  2. Name Convention: Use meaningful names, recommend using application name
  3. User Confirmation: Best to get user confirmation before modifying startup
  4. Permission Note: Some environments may require administrator privileges to modify startup items

VB6 and LOGO copyright of Microsoft Corporation