Search code examples
vb.netvisual-studiovisual-studio-2015configurationmanagersccm

How to open the SCCM Configuration Manager in VB - Visual Studio 2015


I'm creating a tool in VB using Visual Studio 2015 and I'm having some issues with forcing one item on a menu strip when clicked to open the SCCM Configuration Manager.

So far I've tried:

Option 1

Dim ProcID As Integer 
ProcID = Shell("control smscfgrc", AppWinStyle.NormalFocus)

Option 2

Process.Start("cmd.exe", "control smscfgrc")

Option 3

Dim p as Process = new Process()
Dim pi as ProcessStartInfo = new ProcessStartInfo()
pi.Arguments = "control smscfgrc"
pi.FileName = "cmd.exe"
p.StartInfo = pi 

Option 4

Shell=("control smscfgrc", 0)

None of the above work, they just open the console but nothing else.

If I open a regular cmd window using "windows + R" and type the command "control smscfgrc" it open the SCCM Configuration Manager as it should.

I really need this to complete my tool, any help is much appreciated!

Thank you for the time you took to read this.


Solution

  • I'm not a guru with VS nor VB, but your commands to open cmd.exe looks incorrect. You need to add a /c. The command in the Run window (Windows Key + R) would look like this ...

    cmd.exe /c control smscfgrc
    

    Of course, control is actually control.exe, so you don't even need cmd.exe:

    control.exe smscfgrc
    

    Tested and confirmed that this opens the Configuration Manager Properties window from the Run windows on my computer.

    You also may need the full path to control.exe. I would use environment variables; I think this is how it would be done in VB:

    Dim control_exe As String
    control_exe = Environment.GetEnvironmentVariable("SystemRoot") & "\System32\control.exe"
    

    You will automatically get redirected to SysWOW64 if running on as a 32-bit process on a 64-bit OS.

    Option 2

    Process.Start(control_exe, "smscfgrc")
    

    Option 3

    Dim p as Process = new Process()
    Dim pi as ProcessStartInfo = new ProcessStartInfo()
    pi.Arguments = "smscfgrc"
    pi.FileName = control_exe
    p.StartInfo = pi