?
Solved

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

Posted on 2006-05-11
5
Medium Priority
?
357 Views
Last Modified: 2012-06-27
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
0
Comment
Question by:GCaron
  • 3
5 Comments
 
LVL 8

Assisted Solution

by:plq
plq earned 1000 total points
ID: 16662108
Its got to be the dos squiggles ~~~~~~

Dos translates paths using the api calls GetLongPathName or GetFullPathName (A and W) - I doubt that .net would call these.

expand program~1 into "program files" either manually or by calling GetLongPathName win api function. But before you get into this change the paths to the full windows explorer path (program files\....) just to prove the concept
0
 

Author Comment

by:GCaron
ID: 16662590
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?
0
 

Author Comment

by:GCaron
ID: 16662611
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.
0
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 1000 total points
ID: 16663579
Try:

    Dim argString = "-t org -s " & Chr(34) & xmlString & Chr(34) & " -u username -p password"

Also try giving a path to your executable:

    instProc.StartInfo.FileName = "c:\somepath\folders\addobj.exe"

The Working Directory is not the same as the path to your executable...
0
 

Author Comment

by:GCaron
ID: 16684333
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.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses

750 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question