Solved

Passing parameters to a Windows application through C# Process.start

Posted on 2014-03-05
19
513 Views
Last Modified: 2014-04-03
hi

I want to call a Windows Application(a GUI) from C# Process.start, can you suggest me , how can i pass the parameters to the same , it is a third party application , so i myself don't know what are the parameters of the same .
0
Comment
Question by:BeyondBGCM
  • 9
  • 6
  • 4
19 Comments
 
LVL 69

Expert Comment

by:Qlemo
ID: 39907507
How will you know which parameters to provide if you don't know the parameters?
0
 

Author Comment

by:BeyondBGCM
ID: 39908439
yes , is there a way which can extract all available , parameters of the application , exe, so that i can use them.
0
 
LVL 69

Expert Comment

by:Qlemo
ID: 39908676
No. Some applications allow /? or /help to display a list of available parameters, but that is no requirement for apps. Some do if you do not provide any parameter, or a wrong one.
Otherwise you have to find a manual for the application you want to call.
0
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
LVL 33

Expert Comment

by:sarabande
ID: 39909374
if the application is file oriented it often accepts a filename as first parameter.

if the application is associated with a file type you could/should find the functions it offers by right-clicking on a file of that type in the windows explorer. those functions like 'open', 'print', ... you also can find in the windows registry.

if so, you could use winapi function ShellExecute to call these functions programmatically.

Sara
0
 

Author Comment

by:BeyondBGCM
ID: 39912299
but , i don't see those functions there ..... in Windows registry.
0
 
LVL 69

Expert Comment

by:Qlemo
ID: 39912492
1. Try the /help
2. get the docu
3. Use e.g. strings from www.sysinternals.com to extract all strings contained in the exe file, to get an idea of parameter names
4. contact the vendor

If you have exhausted all those options, you are lost.
0
 

Author Comment

by:BeyondBGCM
ID: 39924687
I still believe there should be some way of calling a GUI EXE in our C# code , if not , can i extract the code given in the EXE , to use in my application.
0
 
LVL 69

Expert Comment

by:Qlemo
ID: 39924956
GUI apps are not thought to get automated input. There are exceptions like Office, but those implement a specific interface via COM or similar.
Sometimes you can help yourself by using the Sendkey approach: A simulation of key presses, but that is unreliable.

If you are able to extract the core features you need, that's certainly the best option here.
0
 

Author Comment

by:BeyondBGCM
ID: 39941529
with above discussion , i can conclude , that a GUI exe is not possible to be executed from a C# application. if i am correct , then please close this thread.
0
 
LVL 33

Expert Comment

by:sarabande
ID: 39941596
i can conclude , that a GUI exe is not possible to be executed from a C# application
that is not correct. for a windows application there are multiple common ways to get automated and all these ways could be issued by a c# program if necessary:

1. automation by COM interface
2. automation by .NET services
3. shell automation to a file type and functions like 'open', 'print', ...
4. automation by command line interface
5. automation by hooking into windows messages.

the latter could only done if you have the appropriate rights or if it is your own program which you want to hook. for example test tools like autoit can be used to emulate user interaction to any windows based gui application.

it seems to me it is the lack of information you have which prevents from automation and not so much technical issues. it could help if you tell which application you want to automate.

Sara
0
 

Author Comment

by:BeyondBGCM
ID: 39941949
hi Sara

you can take example of any GUI app, such as PDFToWord , freely available on net.

https://www.google.co.in/url?q=https://www.pdftoword.com/&sa=U&ei=RsoqU_XwL4bGrAeJ0YDYAg&ved=0CBsQFjAA&usg=AFQjCNGzKM5m370YTf43AnjxzVMo5ptSwg

now , how can i pass the arguments , to it using a C# application , and can call it's execute method.
0
 

Author Comment

by:BeyondBGCM
ID: 39941955
the link i have shared is one example only, you can take any application , which has a GUI , a desktop application , and which we can automate in C# application.

please share your comments, for this.
0
 
LVL 69

Expert Comment

by:Qlemo
ID: 39941967
You are so wrong with "you can take any application". The solution is always adapted to the specific application you want to control. Besides what we've told you, there is nothing more to say.
0
 

Author Comment

by:BeyondBGCM
ID: 39943467
http://download.exdat.com/file/HP_LaserJet_6L_(PCL).exe/index-9591.html

you can download AllFileToAllFile converter , and check this.
0
 
LVL 33

Expert Comment

by:sarabande
ID: 39944665
as told you need to get the information which kind of automation is possible by the vendor of the application. nitro pdf (pdftoword) for example have a free trial of their desktop application and a good faq. they also have a server version of their product what means that there is a well-defined interface where clients can pass their files to server and get it back in the required form.

Sara
0
 

Author Comment

by:BeyondBGCM
ID: 39944803
yes , we are on same page now (almost).
1. the desktop version which you are saying is the one , which i want to call using C# , as mostly freeware(not free trial) software are of desktop version, and if i want to use them directly in my programme , i need to pass the parameter and also call their execute command.

2. it is because i have many files to process at once , so i will create a console application , which will execute this code, and will process it for 100 files at once.
0
 
LVL 69

Accepted Solution

by:
Qlemo earned 500 total points
ID: 39944818
There is a reason the software is free, and often it is because you can't automate or otherwise mass-misuse it. Automation is a business use.
0
 

Author Comment

by:BeyondBGCM
ID: 39944825
hmmm, you have a point.....
0
 
LVL 33

Expert Comment

by:sarabande
ID: 39948620
to add: the free version of the conversion utility is a web-based service and allows 5 free conversions a month per user. it is pretty well possible (though beyond my expertise) to call those web-services programmatically. however, if they didn't make a mistake the 5 trials would apply nevertheless.

Sara
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
splitOdd10 challenge 5 104
wordappend challenge 8 172
Non-recursive backtracking, using a stack 1 126
Help Required 2 29
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
A short article about problems I had with the new location API and permissions in Marshmallow
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

813 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now