Stop and Restart WMI Service without System.Management

G

Guest

I have an application that fixes some common problems that prevent the SMS
Advanced Client from operating correctly. During this application I need to
stop the Windows Management Instrumentation (winmgmt) service, delete the
Repository directory, and then restart winmgmt which will then automatically
regenerate the Repository directory. Since I am stopping WMI I cannot use
System.Management to perform this. I have tried:

System.Diagnostics.Process.Start("CMD.EXE", "net pause winmgmt");

but this does not work if I try to use 'net pause' or 'net stop'. I have
successfully used this technique to execute other 'net' commands, but this
one will not work. The command 'net stop winmgmt' does work if I do this
manually at the cmd prompt outside of an application. Any help would be
greatly appreciated.
 
W

Willy Denoyette [MVP]

System.Diagnostics.Process.Start("net", " pause winmgmt");
'net.exe' is not a command interpreter built-in it's a program.

Willy.

|I have an application that fixes some common problems that prevent the SMS
| Advanced Client from operating correctly. During this application I need
to
| stop the Windows Management Instrumentation (winmgmt) service, delete the
| Repository directory, and then restart winmgmt which will then
automatically
| regenerate the Repository directory. Since I am stopping WMI I cannot use
| System.Management to perform this. I have tried:
|
| System.Diagnostics.Process.Start("CMD.EXE", "net pause winmgmt");
|
| but this does not work if I try to use 'net pause' or 'net stop'. I have
| successfully used this technique to execute other 'net' commands, but this
| one will not work. The command 'net stop winmgmt' does work if I do this
| manually at the cmd prompt outside of an application. Any help would be
| greatly appreciated.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top