• 本站域名:OceanCoder.cn 若您喜欢本站,请添加至收藏夹!
  • 网站少部分资源来源自网络,如有侵犯您的权益,请联系站长删除!
  • 本站所有文章,除特殊标明外,皆为本人原创,转载请注明出处,谢谢合作!
  • 本站所下载的资源,若无特殊说明,使用统一解压密码:oceancoder.cn
  • 本站已实现布局自适应,支持手机端、pad端访问,欢迎体验
  • 本站部分资源可通过微信公众号留言获取,欢迎体验

C#通过cmd向IDM添加下载任务

C# OceanCoder 2019-01-13 6705 次浏览 0个评论

通过命令参数向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


已有 6705 位网友参与,快来吐槽:

发表评论