Link to home
Start Free TrialLog in
Avatar of brokeMyLegBiking
brokeMyLegBiking

asked on

trying to run "NET START" command using ProcessStart


I have the following code, which I am trying to run to start my SQL server which I just installed. However, I get the error "the system cannot find the file specified."

--------
        Dim p As New Process
        p.StartInfo.FileName = "net start mssql$DATALINKDB"
        p.Start()
        p.WaitForExit()

-----------

do I need to add a prefix, or add the name of an actual program to execute the NET START statement or something?

Avatar of Zamba1
Zamba1

Doesn't work that way.
You have to separate the filename and its parameters:

        Dim p As New Process
        p.StartInfo.FileName = "net"
        p.StartInfo.Arguments = "start mssql$DATALINKDB"
        p.Start()
        p.WaitForExit()
Why not just:

        Process.Start("net", "start mssql$DATALINKDB")
I saw the code snippet and had to correct it immediately. Not perfect but working :-)
ASKER CERTIFIED SOLUTION
Avatar of Zamba1
Zamba1

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of brokeMyLegBiking

ASKER

excellent, the serviceController class is even better!