Click here to Skip to main content
15,886,873 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, I try to send more commands (arguments) in one process start

New I have only for one argument: rut_ors_p its working but I need
add messagesrv_p and etl_p to this start, is it possible?

What I have tried:

C#
string strCmdText = ("rut_ors_p");
isnt good I know.

C#
            string rut_ors_p = "-cshost xyz -csport 1234 -scshost xyz  -scsport 2589 -csappname default  -csuser user -cspassword aaaa -switchapp rut_ors_p";
            string rut_messagesrv_p = "-cshost xyz -csport 1234 -scshost xyz  -scsport 2589 -csappname default  -csuser user -cspassword aaaa -switchapp rut_messagesrv_p";

string etl_p = "-cshost xyz -csport 1234 -scshost xyz  -scsport 2589 -csappname default  -csuser user -cspassword aaaa -switchapp etl_p";
            
            myProcess.StartInfo.UseShellExecute = false;
            myProcess.StartInfo.CreateNoWindow = true;
            myProcess.StartInfo.RedirectStandardInput = true;
            myProcess.StartInfo.RedirectStandardOutput = true;
            myProcess.StartInfo.RedirectStandardError = true;
            string strCmdText = ("rut_ors_p");
            Process.Start(@"C:\Users\zzzz\Documents\SCServer_mlcmd\mlcmd.exe", rut_ors_p);
Posted
Updated 28-Jun-23 6:46am
v2

You could write those commands out to a .bat file in a temporary folder then use Process.Start on that batch file
 
Share this answer
 
I've no access to the EXE file (I assume it's a Genesys thing) but there are two ways you can try: concatenating the parameter strings together with spaces between them:
C#
Process.Start(@"C:\Users\zzzz\Documents\SCServer_mlcmd\mlcmd.exe", String.Join(" ", rut_ors_p, rut_messagesrv_p, etl_p);
Or issue three separate Start commands:
C#
Process.Start(@"C:\Users\zzzz\Documents\SCServer_mlcmd\mlcmd.exe", rut_ors_p);
Process.Start(@"C:\Users\zzzz\Documents\SCServer_mlcmd\mlcmd.exe", rut_messagesrv_p,);
Process.Start(@"C:\Users\zzzz\Documents\SCServer_mlcmd\mlcmd.exe", etl_p);
Which you need is up to how the app was written in the first place.
 
Share this answer
 
Comments
Member 15251555 29-Jun-23 8:01am    
thank you Griff.
OriginalGriff 29-Jun-23 8:22am    
You're welcome!
Member 15251555 29-Jun-23 8:13am    
I have one question. I have a lot of keys in config file, how can I read all keys and use it in start process?
e.g.:
<add key="mlcmd" value="C:\Users\cen65842\Documents\SCServer_mlcmd\mlcmd.exe">
<add key="switch_app" value="xyz">
<add key="rut_messagesrv_p" value="abx">
<add key="rut_ors_p" value="abb">
...



Here is my code:
Process.Start(mlcmd, switch_app + rut_messagesrv_p);
Process.Start(mlcmd,switch_app + rut_ors_p);
.etc
.
.
I dont want declare all keys in single row but as complex, now I have:
string mlcmd = ConfigurationManager.AppSettings["mlcmd"];
string switch_app = ConfigurationManager.AppSettings["switch_app"];
string rut_messagesrv_p = ConfigurationManager.AppSettings["rut_messagesrv_p"];
string rut_ors_p = ConfigurationManager.AppSettings["rut_ors_p"];
OriginalGriff 29-Jun-23 8:23am    
Depends on the app and how it's written.
Best way is "try it and see what happens" in a command line manually.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900