Running program in Explorer (detect)

        Dim bExplorer As Boolean = False

        Dim myPID As Integer = System.Diagnostics.Process.GetCurrentProcess().Id

        Dim myParentProcessName As String = ""

        Dim objWMIService, objProcess, colProcess

        Dim myPPID As Integer

        objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")

        colProcess = objWMIService.ExecQuery("Select * from Win32_Process where ProcessID=" & myPID)

        For Each objProcess In colProcess

            myPPID = objProcess.ParentProcessID()

            Try

                myParentProcessName = (Process.GetProcessById(myPPID).ProcessName).ToString()

                If myParentProcessName <> "cmd" Then bExplorer = True

            Catch

                'May have elevated

                bExplorer = True

            End Try

        Next

        If bExplorer Then

            sMachineName = InputBox("What machine would you like to connect? Leave blank for localhost")

        Else

            Try

                sMachineName = arguments(1)

            Catch

                debug.print("You must specify a remote machine")

                End

            End Try

        End If

        If bExplorer Then

            Debug.Print("press ENTER to quit")

            Console.ReadLine()

        End If

Command Line Arguments

        Dim arguments As String() = Environment.GetCommandLineArgs()

        If arguments.Length > 1 Then

            'Console.ForegroundColor = ConsoleColor.Blue

            Console.WriteLine("Machine: " & arguments(1).ToString)

           

        End If