0

I try to call the esriRegAsm.exe with arguments from a C# program. The purpose is to register a Dll. Therefore I usually call the esriRegAsm.exe with the Dll as argument plus some additional parameters (/p:Desktop /s). This works fine if I type it into cmd.exe. Somehow I think that the process sends only the first string to the cmd and not the whole argument list, but I need the "" for the space character in the paths. For debugging I added a message box and the strings seems to be okay.

Backslash or double backslash seems to be unimportant.

 string targetDir = this.Context.Parameters["targ"]; string programFilesFolder = this.Context.Parameters["proFiles"]; System.Diagnostics.Process process = new System.Diagnostics.Process(); System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo(); startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; startInfo.FileName = "cmd.exe"; startInfo.Arguments = "/C \"" + programFilesFolder + "Common Files\\\\ArcGIS\\\\bin\\\\esriRegAsm.exe\" " + "\"" + targetDir + "RArcGISTest.dll\" /p:Desktop /s"; MessageBox.Show("/C \"" + programFilesFolder + "Common Files\\\\ArcGIS\\\\bin\\\\esriRegAsm.exe\" " + "\"" + targetDir + "RArcGISTest.dll\" /p:Desktop /s"); process.StartInfo = startInfo; process.Start(); 

As I cannot attache a picture of the message box... the output is:

/C "C:\Program Files (x86)\Common Files\ArcGIS\bin\esriRegAsm.exe" "C:\install\RArcGISTest.dll" /p:Desktop /s"

1
  • And the question is ...? Commented Mar 21, 2012 at 22:45

1 Answer 1

1

Why are you double-escaping things, and why are you routing it through cmd.exe? Just execute the process directly:

string targetDir = this.Context.Parameters["targ"]; string programFilesFolder = this.Context.Parameters["proFiles"]; Process process = new Process(); ProcessStartInfo startInfo = new ProcessStartInfo(); startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; startInfo.FileName = Path.Combine(programFilesFolder, @"Common Files\ArcGIS\bin\esriRegAsm.exe"); startInfo.Arguments = "\"" + Path.Combine(targetDir, "RArcGISTest.dll") + "\" /p:Desktop /s"; process.StartInfo = startInfo; process.Start(); 
Sign up to request clarification or add additional context in comments.

1 Comment

works for me :) thank you... I double escaped it because I saw something similar for the targetDir string. And yes, it its stupid to use the command line.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.