18
Answers

Bypass load form & Passing Values to called program textbox & click btn

ic ic

ic ic

15y
7.8k
1

Good day, I got calling another program working.
string root = Application.StartupPath;
string exePath = System.IO.Path.Combine(root, "i:\\app\\test\\WAREH004.exe");
string argPath = System.IO.Path.Combine(root, "i:\\app\\test\\WAREH004.INI");
Process.Start(exePath, argPath + " 1");

I need help:
The program i'm calling has the same load form that the current one uses.
1. How do i bypass the load form & load the main form with the forms values i selected on the current program?
2. How do i also pass values to the called programs textbox & click a button?

Please Assist!

Answers (18)
0
ic ic

ic ic

NA 85 0 15y


Unfortunatley still not working: i tried Insert(1,"1")
also tired both after one another:
p.StartInfo.Arguments.Insert(0, str);
p.StartInfo.Arguments.Insert(1, "1");

could it be that the program i'm calling does not have arguments setup:
public frmWAREH004S() {
??
0
naura pax

naura pax

NA 1.9k 64.8k 15y

what are you doing.
you are inserting arguments in a list so it should be like
Insert(0,str);
Insert(1,"1"); two statements one after another.
args is a collection of arguments
in the end it will execute like this-- programname "arg1" "arg2".
I hope you get it this time.
0
ic ic

ic ic

NA 85 0 15y

Hi,
I got it to pass the arguments by removing the insert:  p.StartInfo.Arguments = str + @" 1";
The problem i now have is that it calls the login frm the first frm & the same frm my current one has already completed.
I would like to bypass the login load frm and go straight to the Main frm of the other program!
??
0
ic ic

ic ic

NA 85 0 15y

:(   no luck
string str = @"i:\\app\\test\\WAREH004.ini";
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.FileName = @"i:\\app\\test\\WAREH004.exe";
p.StartInfo.Arguments.Insert(1, "1");
p.Start();

I tried: Insert(0, "1");  Insert(0, "1" + str);  Insert(1, "1" + str); Insert(0, str + " 1");
if i put a break and i pass the insert i can see the arguments are blank

0
naura pax

naura pax

NA 1.9k 64.8k 15y

It seems pretty obvious to me..
just insert another argument
Insert(1,"1");
and don't add "1" after the .ini filename. I think that's what you are doing.
and please mark as answered if you get it this time. :)
0
ic ic

ic ic

NA 85 0 15y

I'm gratefull for your help - please don't give up.
Unsuccessfull, the 0 index opens only the exe & if i put the 1 in then i get the same error as previous.
string str = @"i:\\app\\test\\WAREH004.ini";
System.Diagnostics.
Process p = new System.Diagnostics.Process();
p.StartInfo.FileName =
@"i:\\app\\test\\WAREH004.exe";
p.StartInfo.Arguments.Insert(0, str);
p.Start();
0
naura pax

naura pax

NA 1.9k 64.8k 15y

index starts from 0 and you have entered 1.
besides you can use a string variable
string str=@"......filename.ini";
and pass string in insert
Insert(0,str)
0
ic ic

ic ic

NA 85 0 15y

I added the @ but when I call the program i get the error:
{"Index was out of range. Must be non-negative and less than the size of the collection.\r\nParameter name: startIndex"}
0
naura pax

naura pax

NA 1.9k 64.8k 15y

please specify error, or at least type and nature of error.
btw in this code-
 p.StartInfo.Arguments.Insert( 1, "i:\\app\\test\\WAREH004.ini"); 

 

 
once again you forgot to specify verbatim @"i:\\app\\test\\WAREH004.ini"
 
0
ic ic

ic ic

NA 85 0 15y

Hi, Not winning - still does not work!
p.StartInfo.FileName =
@"i:\\app\\test\\WAREH004.exe";
p.StartInfo.Arguments.Insert( 1, "i:\\app\\test\\WAREH004.ini");
The other problem is that this would take me to the startup from of the other program & want to bypass this startup frm because it is the same statup frm of the current application & pass the value I selected on the current startup frm to the other program?
Please Help?
0
naura pax

naura pax

NA 1.9k 64.8k 15y

hey
try and understand..
"i:\\app\\test\\WAREH004.exe i:\\app\\test\\WAREH004.ini 1" is not a filename
it looks like dos command rather
you will have to specify "i:\\app\\test\\WAREH004.exe" as filename and insert 2 arguments using insert method of the Process.Args
for "i:\\app\\test\\WAREH004.ini" and "1".
I hope i'm clear now.
0
ic ic

ic ic

NA 85 0 15y

The app gets loaded with ini parameter of 1 and if i run the exe only it does not work & the below method it does not find the file again: Please Help

System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.FileName = @"i:\\app\\test\\WAREH004.exe i:\\app\\test\\WAREH004.ini 1";
p.StartInfo.Arguments.Insert(0, txtSite.Text);
p.Start();
0
naura pax

naura pax

NA 1.9k 64.8k 15y

hey ic ic,
what are you doing here:
 p.StartInfo.FileName = "i:\\app\\test\\WAREH004.exe" + 
" i:\\app\\test\\WAREH004.INI" + " 1"; 

you should add just one filename and that too of an executable. And please use verbatim before a string with special characters.
 
p.StartInfo.FileName = @"i:\\app\\test\\WAREH004.exe";
 
0
ic ic

ic ic

NA 85 0 15y

Thank You for Helping.
I cant seem to get the file location working on this method:
//string root = Application.StartupPath;
//string exePath = System.IO.Path.Combine(root, "i:\\app\\test\\WAREH004.exe");
//string argPath = System.IO.Path.Combine(root, "i:\\app\\test\\WAREH004.INI");
//Process.Start(exePath, argPath + " 1");
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.FileName = "i:\\app\\test\\WAREH004.exe" + " i:\\app\\test\\WAREH004.INI" + " 1";
p.StartInfo.Arguments.Insert(0, txtSite.Text);
p.Start();
0
naura pax

naura pax

NA 1.9k 64.8k 15y

hey ic ic,
here is one way.
 
System.Diagnostics.
Process p = new System.Diagnostics.Process();
p.StartInfo.FileName =
"your path goes here";
p.StartInfo.Arguments.Insert(0,
"dlfsd");
p.Start();

 
0
ic ic

ic ic

NA 85 0 15y

Please Help - I would like to get this going any ideas!
Reall yapprecaite any help - because I'm searching all over the net for solutions :)
0
ic ic

ic ic

NA 85 0 15y

Some code examples please on how & what i can try?
public
frmWAREH010()  - Also has no arguments!
0
Roei Bar

Roei Bar

NA 7.8k 0 15y

well you can just start working with command line arguments and pass the information you need via args[]
and if so load the form based on the args information
the exe has on Program.cs on the Main Method args in the method signature
check if its not empty and if so work with the information in it