通过命令参数向Internet Download Manager[IDM] 添加下载任务。。
public void SendLinkToIdm(string url) { try { bool x_32 = System.IO.Directory.Exists(@"C:\Program Files\Internet Download Manager"); // check if system is 32bit bool x_64 = System.IO.Directory.Exists(@"C:\Program Files (x86)\Internet Download Manager"); // check if system is 64bit and you have installed 32bit programs on it if (x_32 == true | x_64 == true) // if any of the above directories exist it means you have idm installed { System.Diagnostics.Process p = new System.Diagnostics.Process(); // Start the child process. p.StartInfo.UseShellExecute = false; // Set the useshellExecute to false p.StartInfo.RedirectStandardOutput = true; // Redirect the output stream of the child process. p.StartInfo.FileName = @"C:\Windows\System32\cmd.exe"; // specify the location of the command line p.StartInfo.Verb = "runas"; p.StartInfo.CreateNoWindow = true; // eliminate the process window if(x_32 == true) p.StartInfo.Arguments = @"/C cd %programfiles%\Internet Download Manager && IDMan.exe /d " + "\"" + url + "\""; // first go to the idm location then execute the command else p.StartInfo.Arguments = @"/C cd C:\Program Files (x86)\Internet Download Manager && IDMan.exe /d " + "\"" + url + "\""; p.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; p.Start(); // now when all is set run the process p.WaitForExit(); // Waits here for the process to exit. } else MessageBox.Show("Please install Internet Download Manager " + System.Diagnostics.Process.Start("https://www.internetdownloadmanager.com/download.html")); // open the download page of the idm in the browser } catch (Exception ex) { MessageBox.Show(ex.Message); } }
调用方式:
SendLinkToIdm("http://XXX.rar");
关于idm更多的命令行参数:
以下内容来自官网,英文比较简单,不翻译了
You may start IDM from the command line using the following parameters
idman /s
or idman /d URL [/p local_path] [/f local_file_name] [/q] [/h][/n] [/a]
Parameters:
/d URL - downloads a file
e.g. IDMan.exe /d "http://www.internetdownloadmanager.com/path/FileName.zip"
/s - starts queue in scheduler
/p local_path - defines the local path where to save the file
/f local_file_name - defines the local file name to save the file
/q - IDM will exit after the successful downloading. This parameter works only for the first copy
/h - IDM will hang up your connection after the successful downloading
/n - turns on the silent mode when IDM doesn't ask any questions
/a - add a file specified with /d to download queue, but don't start downloading
Parameters /a, /h, /n, /q, /f local_file_name, /p local_path work only if you specified the file to download with /d URL
已有 7527 位网友参与,快来吐槽:
发表评论