Feedback

Auflistung aller auszuführenden StartUp Commands

Sprache: VB

Der nachfolgende Code listet alle Startupcommandos eines Systems auf und gibt sie als String wieder aus. Dies kann zur Diagnose herangezogen werden
Function GetAllStartUpCommands() As String
        Dim s As New StringBuilder
        Dim strComputer As String = "."
        Dim objWMIService As Object = GetObject("winmgmts:" _
            & "{impersonationLevel=impersonate}!\" & strComputer & "rootcimv2")

        Dim colStartupCommands As Object = objWMIService.ExecQuery _
            ("Select * from Win32_StartupCommand")

        For Each objStartupCommand As Object In colStartupCommands
            s.AppendLine("Command: " & objStartupCommand.Command)
            s.AppendLine("Description: " & objStartupCommand.Description)
            s.AppendLine("Location: " & objStartupCommand.Location)
            s.AppendLine("Name: " & objStartupCommand.Name)
            s.AppendLine("Setting ID: " & objStartupCommand.SettingID)
            s.AppendLine("User: " & objStartupCommand.User)
            s.AppendLine("")
        Next
        Return s.ToString
End Function
Function GetAllStartUpCommands() As String
        Dim s As New StringBuilder
        Dim strComputer As String = "."
        Dim objWMIService As Object = GetObject("winmgmts:" _
            & "{impersonationLevel=impersonate}!\" & strComputer & "rootcimv2")

        Dim colStartupCommands As Object = objWMIService.ExecQuery _
            ("Select * from Win32_StartupCommand")

        For Each objStartupCommand As Object In colStartupCommands
            s.AppendLine("Command: " & objStartupCommand.Command)
            s.AppendLine("Description: " & objStartupCommand.Description)
            s.AppendLine("Location: " & objStartupCommand.Location)
            s.AppendLine("Name: " & objStartupCommand.Name)
            s.AppendLine("Setting ID: " & objStartupCommand.SettingID)
            s.AppendLine("User: " & objStartupCommand.User)
            s.AppendLine("")
        Next
        Return s.ToString
End Function

2 Kommentare

  1. Für welche VB-Version ist das?
    Bei mir gibt es unter VB2010 direkt einige Fehlermeldungen.
    So kann VB bei mir nichts mit „Stringbuilder“ anfangen.

  2. StringBuilder ist eine Klasse aus dem System.Text-Namespace, welcher via
    [code]Import System.Text[/code]
    erst importiert werden muss.

    BTW, warum nutzt du VB 2010? Die Version ist doch schon etwas älter und mit den neueren kann man teilweise deutlich mehr machen.