Skip to content

cStartUp Methods Reference

Toggle

Toggles auto-start item with specified name. Adds if not exists, removes if exists.

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

Parameters

ParameterTypeDescription
NameStringStartup item name (displayed in registry)
PathVariantProgram path, supports two formats: App object or string path
StartArgsVariantOptional, startup parameter array (ParamArray)

Return Value

  • True - Toggle successful
  • False - Toggle failed, get error info via LastError

Examples

vb
' Auto extracts App.Path and App.EXEName
VBMAN.StartUp.Toggle "MyApp", App

Pass String Path

vb
' Specify full path directly
VBMAN.StartUp.Toggle "MyApp", "C:\Program Files\MyApp\MyApp.exe"

With Startup Parameters

vb
' Pass multiple startup parameters
VBMAN.StartUp.Toggle "MyApp", App, "--minimized", "--start-in-tray"

Complete Usage Flow

vb
Private Sub MenuStartUp_Click()
    Dim Result As Boolean
    
    ' Toggle auto-start status
    Result = VBMAN.StartUp.Toggle("cs-auther-client", App)
    
    If Result Then
        ' Update menu check state
        MenuStartUp.Checked = VBMAN.StartUp.Has("cs-auther-client")
        
        ' Show hint
        If MenuStartUp.Checked Then
            VBMAN.Toast.Show "Set auto-start"
        Else
            VBMAN.Toast.Show "Cancelled auto-start"
        End If
    Else
        ' Show error
        MsgBox "Setting failed: " & VBMAN.StartUp.LastError, vbExclamation
    End If
End Sub

Has

Checks if specified startup item exists.

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

Parameters

ParameterTypeDescription
NameStringStartup item name

Return Value

  • True - Startup item exists
  • False - Startup item does not exist

Examples

vb
' Check if exists
If VBMAN.StartUp.Has("MyApp") Then
    Debug.Print "Auto-start set"
Else
    Debug.Print "Auto-start not set"
End If

' Used to set menu check state
MenuStartUp.Checked = VBMAN.StartUp.Has("MyApp")

Usage Mode Comparison

ScenarioCode Example
Add startup itemToggle("App", App) - Add if not exists
Remove startup itemToggle("App", App) - Remove if exists
Toggle startup itemToggle("App", App) - Auto toggle status
Check statusHas("App") - Return boolean

Error Handling

vb
If Not VBMAN.StartUp.Toggle("MyApp", App) Then
    ' Handle error
    Dim ErrMsg As String
    ErrMsg = VBMAN.StartUp.LastError
    
    MsgBox "Auto-start setting failed: " & ErrMsg, vbCritical
End If

VB6 and LOGO copyright of Microsoft Corporation