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 BooleanParameters
| Parameter | Type | Description |
|---|---|---|
Name | String | Startup item name (displayed in registry) |
Path | Variant | Program path, supports two formats: App object or string path |
StartArgs | Variant | Optional, startup parameter array (ParamArray) |
Return Value
True- Toggle successfulFalse- Toggle failed, get error info viaLastError
Examples
Pass App Object (Recommended)
vb
' Auto extracts App.Path and App.EXEName
VBMAN.StartUp.Toggle "MyApp", AppPass 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 SubHas
Checks if specified startup item exists.
vb
Public Function Has(ByVal Name As String) As BooleanParameters
| Parameter | Type | Description |
|---|---|---|
Name | String | Startup item name |
Return Value
True- Startup item existsFalse- 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
| Scenario | Code Example |
|---|---|
| Add startup item | Toggle("App", App) - Add if not exists |
| Remove startup item | Toggle("App", App) - Remove if exists |
| Toggle startup item | Toggle("App", App) - Auto toggle status |
| Check status | Has("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