As the title says, it is possible to launch Download Manager (such as Orbit) passing the URL of the file to download?
Edit:
How can I check how those programs are expecting the url???
What parameters are needed to be passed ??
My problem is , I do NOT know how those programes are expecting their inputs.
Before that, I also would like to check if one of download managers has installed in the machine.
If you want to start an application from C# you can create a new process of the .exe file of the application and if that application supports arguments you can add them also. So you will need to find out if Orbit accepts arguments. The example below shows how to start a new process with arguments. Please note that the application will start out of the process of your own application.
string args = " \"" + URL + "\"";
ProcessStartInfo psi = new ProcessStartInfo("path to Orbit", args);
Process p = Process.Start(psi);
string path = #"C:\Program Files\Orbit\Orbit.exe";
string arg = #"http://www.example.com/file.ext";
System.Diagnostics.Process.Start(path, arg);
There is no way to find an abstract downloader on a computer and launch it directly to download a file.
Only one idea I have - launch a browser and hope it will download file by itself or launch a registered downloader:
Process.Start("http://example.com/file.ext");
If the download manager accepts url arguments then you can start a process and pass the desired URL to it
Process.Start("Orbit.exe -http://www.something.com/file.ext");
So this approach highly depends on the download manager.
I guess it is kind of depends in the download manager.
If it has support for command line arguments with the file location URL then you can use the System.Diagnostics.Process class.
Related
I have an IE plugin which adds buttons in a page where there are pdf links and opens them in a specific application when clicked.
Lets say I need to open a xyz.pdf file in abc.exe application. abc is not the default application for file type .pdf.
In one machine the below works
Process p = Process.Start("pathtoabc.exe", "pathtoxyz.pdf");
In another machine it only works if I make abc.exe as the default app and then use the below
Process p = Process.Start("pathtoxyz.pdf");
Can you give me any pointers please? I also tried using ProcessStartInfo with no change
Updates:
I tried using the default Acrobat reader with an argument
Argument for processstartinfo looks like this "C:\PDF Files\Professional-Letters-Guide.pdf"
FileName = "C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe"
Result - Acrobat reader opens but with an error message "File not found". The is available in the path though.
Solved:
It was a space in the Foldername.. solved it by enclosing the filename with quotes "\""
Thank you all for the suggestions.. they helped me think it through.
Have you tried qualifying the Process.StartInfo.Arguments value with quotes and the full path to the file? What about the WorkingDirectory property? Also, the previous assertion regarding confirmation of the application being called supporting command line parameters is absolutely valid. You can be fooled into thinking that it does due to operating system file extension associations specific to a machine.
The second parameter of the Process.Start is passed to the application you are trying to start and it wont open the file using this application "pathtoabc.exe" unless the application "pathtoabc.exe" accepts the file name as a startup argument.
So you need to check if the application you are trying to use supports this kind of argument.
I'm writing code that will start a download from our company's ftp (ftp://...) but when using Process.Start("ftp://..."); Windows will prompt me for an app to open it with (I'm using Windows 10). If I use Process.Start("http://www.google.com"); it doesn't prompt. How do I avoid this prompt and just navigate the user to the ftp URL?
Windows knows what to do with a URL that starts with http: open the default web browser and browse to that URL. However, it doesn't natively know what to do with a URL that starts with ftp.
When you're using Process.Start, think of it like running a command from the "run" line in Windows. You usually need to specify an executable to run, and any additional information -- i.e. arguments to the executable -- occur after the path or executable name.
In this case, I'd say you just want to start Internet Explorer and provide it your URL as an argument:
var psi = new ProcessStartInfo(Environment.ExpandEnvironmentVariables(#"%ProgramFiles%\Internet Explorer\iexplore.exe"), url);
var proc = Process.Start(psi);
EDIT: to answer your question about using the default browser, see this SO answer about how to get the default browser's path:
I have an exe file of a console application that takes parameter as:
A.exe --i=123 --o=abc
The out is a generic tsv file created at a predefined output folder.
For some reason I need to develop a web application which can call A.exe (such that input parameters are passed as request parameters) and return the content of the file as a web response.
Something like:
www.myserver.com/A?i=123?o=abc
Can someone suggests few pointers to get started?
You can try using Process as follows,
Process proc = new Process();
proc.EnableRaisingEvents = false;
proc.StartInfo.FileName = Path.Combine(exePath, #"A.exe");
proc.StartInfo.Arguments = String.Format(#"-i = ""{0}"" -o = ""{1}""", "123", "abc");
proc.Start()
Note : Set proper permission to the application pool to run this application.
Make a dll of your exe and call it from asp.net handler .ashx
It is a better option.
Alright, I've figured out my issue. I am using some software to remotely start programs on local computers. In doing so, I send a path across the network of a program that I want that machine to start. It uses Process.Start and stores the executing path. I then, later, resend that path and tell it close the Process that was associated with this path.
Process newProcess = Process.Start(startPath);
_runningProcesses.Add(new MCProcess(startPath, new Process);
Sometimes, I will use this to call a shortcut, which I use because I want to pass some command link arguments along with.
I've used this to call .exe and .lnk (shortcut extension) and it runs the programs just fine.
However, when passing in the path to a shortcut, the process that it returns is null! Therefor, when I send the path back to close the program, the process is null and it can't close the program.
Any solutions?
You don't need shortcut to pass arguments to the program, just do following:
Process process = new Process();
process.StartInfo.FileName = "\"C:\\my.exe\"";
process.StartInfo.Arguments = "arg1 arg2 arg3";
//...
process.Start();
In command line it would look like C:\my.exe arg1 arg2 arg3
just take the target of the shortcut if its necessary to use the shortcut.
Get target of shortcut folder
I would like to integrate FileZilla with my application written in C#.
please someone show me sample code or web site that shows sample code.
although i found article on web, and that article was saying
"application is integrated with FileZilla is so slow".
but i don't know if i can stand that late or not.
so i would like to challenge.
To support FTP/SFTP or any other protocol in C# you can do it in 3 ways:
1. NEW APP PROCESS - Start an app that does the FTP communication in separate process, and be able to control what file to download, where to save it and to tell the app to terminate when download is finished. This way, you can use FileZilla only if it lets you pass certain parameters in command line, like the URI of the resource you want to transfer through FTP/SFTP, and the path where the file should be saved to. And as I can see HERE this could work.
To start the process and pass it command line arguments in C# you would do something like this:
static void StartNewProcess(string app, string args)
{
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = app; //full app path
startInfo.Arguments = args; //command line arguments
startInfo.CreateNoWindow = true; //dont create app window
startInfo.WindowStyle = ProcessWindowStyle.Hidden; //hide app from taskbar
Process.Start(startInfo);
}
Now you can execute FileZila app, pass it args containing file URL and let it do its job... But you cant know how long will it take to download the file, when the download is ended, do you need to log in to get it...
2. EXISTING CLASS LIBRARY - Include a Class Library that is written by someone else, that does the job. This way you are in TOTAL control of the process. And as many other suggested, this would be a perfect way for you. Many answers here contain good class libraries that you can use and be happy with the results.
3. HOME-MADE CLASS LIBRARY - Open RFC 959, read it all and write your code... (Now 2. sounds better, doesn't it? :D)
Filezilla is a GUI FTP client, you can't use it to "script" SFTP operations (it only accepts a very limited set of command line arguments).
You must seek a third party C# component or write one yourself (not recommended) to do the job.
To support FTP or SFTP from your C# application, you could use an external library like the one from Chilkat http://www.chilkatsoft.com/ftp-2-dotnet.asp. I use it and it works great!
In theory, you could also implement the FTP protocoll using socket connections by yourself, but you should save yourself that trouble -> don't reinvent the wheel...
I recommend using SharpSSH, if you need to send files via SSH/SFTP in your application.