C # calls cmd and downloads files using IDM

Source: Internet
Author: User

  Public Static voidRuncmd (stringcmd) {stringCmdpath =@"C:\Windows\System32\cmd.exe"; CMD= cmd. Trim (). TrimEnd ('&') +"&exit"or//To add the Exit command, or later call ReadToEnd () command will be suspended animationusing(Process p =NewProcess ()) {p.StartInfo.FileName=Cmdpath; P.startinfo.useshellexecute=false; P.startinfo.redirectstandardinput=true; P.startinfo.redirectstandardoutput=true; P.startinfo.redirectstandarderror=true; P.startinfo.createnowindow=true;                P.start ();                P.standardinput.writeline (CMD); P.standardinput.autoflush=true;                p.WaitForExit ();            P.close (); }        }

Call:

   stringSidmpath =@"E:\Software\idman_lv\IDM\IDMan.exe"; stringSdownloadpath= "http://pan.baidu.com/s/...";//Net-disk linkstringSoutputpath =@"D:\TempFolder\"; stringSfilename= Guid.NewGuid (). ToString () + ". pdf"; stringScmd =string. Format (@"{0}/d "" {1} ""/P "" {2} ""/F "" {3} """, Sidmpath, Sdownloadpath, Soutputpath, sfilename); Cmdbox.appendtext (Scmd+"\ n"); Sqlprocs.runcmd (scmd);

Note: If there are spaces in the calling program path, the cmd command fails to execute and can be enclosed in double quotation marks.

C # calls cmd and downloads files using IDM

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.