Link to home
Start Free TrialLog in
Avatar of GCaron
GCaron

asked on

process.start results in "The system cannot find the file specified"

When trying to run the following code I get the "The system cannot find the file specified" error. I have tried a WorkingDirectory of just "d:\cli" after creating the directory and copying the addobj.exe file there as well but get the same error.

    Public Function installNewDomain(ByVal xmlString As String) As String
        Dim instProc As Process = New Process
        Dim argString = " -t org -s " + """ + xmlString + """ + " -u username -p password"
        instProc.StartInfo.FileName = "addobj.exe"
        instProc.StartInfo.WorkingDirectory = "d:\progra~1\Ensim\WEBppl~1\cli\"
        instProc.StartInfo.Arguments = argString
        Try
            instProc.Start()
        Catch ex As Exception
            Return ex.Message
        End Try
        Return "Success"
   End Function
I've tried variations of shell as well but get the error "file not found"

    Public Function shellNewDomain(ByVal xmlString As String) As String
        Dim argString = " -t org -s " + xmlString + " -u username -p password"
        Dim appPath As String = "d:\progra~1\Ensim\WEBppl~1\cli\addobj.exe"
        Dim shellCall As String = appPath + argString
        Dim ProcID As Integer
        Try
            ProcID = Shell(shellCall, AppWinStyle.Hide, True, 10000)
        Catch ex As Exception
            Return ex.Message
        End Try
        Return "Success"

    End Function

I know the path is correct, I can cut and paste the path into the run box and the exe executes.

Any thoughts?

Regards,

Greg
SOLUTION
Avatar of plq
plq
Flag of United Kingdom of Great Britain and Northern Ireland image

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 GCaron
GCaron

ASKER

I had previously tried using just d:\cli\ to see if the progra~1 and/or program files was the issue but had the same result.

I've now updated to;

    Public Function shellNewDomain(ByVal xmlString As String) As String
        Dim argString = " -t org -s " + xmlString + " -u username -p password"
        Dim appPath As String = "d:\Program Files\Ensim\WEBppliance\cli\addobj.exe"
        Dim shellCall As String = appPath + argString
        Dim ProcID As Integer
        Try
            ProcID = Shell(shellCall, AppWinStyle.Hide, True, 10000)
        Catch ex As Exception
            Return ex.Message
        End Try
        Return "Success"

    End Function


    Public Function installNewDomain(ByVal xmlString As String) As String
        Dim instProc As Process = New Process
        Dim argString = " -t org -s " + """ + xmlString + """ + " -u username -p password"
        instProc.StartInfo.FileName = "addobj.exe"
        instProc.StartInfo.WorkingDirectory = "d:\program files\Ensim\WEBppliance\cli\"
        instProc.StartInfo.Arguments = argString
        Try
            instProc.Start()
        Catch ex As Exception
            Return ex.Message
        End Try
        Return "Success"

and receive the same results of "The system cannot find the file specified" and "file not found".

Any other ideas?
Avatar of GCaron

ASKER

Also, I just tried copying the cli directory and exe file to c:\ and used c:\cli\addobj.exe with the same results.

If it matters, this is on a Windows 2003 server.
ASKER CERTIFIED SOLUTION
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

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 GCaron

ASKER

Still having an issue with the code on my 2003 server but have tested the final code on windows 2000 and it works as expected. As I have incorporated parts of both answers I have split the points.

Thank you both for you time and assistance.