亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

創建bat文件來下載程序但我找不到問題

創建bat文件來下載程序但我找不到問題

子衿沉夜 2023-12-14 15:51:29
說網址錯誤,但對我來說似乎是正確的。我正在嘗試從互聯網下載文件啟動該程序,然后在該過程結束后刪除該程序。任何幫助都會很棒過程將是啟動exe ---> 創建簡單的下載器 ---> 通過bat文件添加參數 ---> 啟動文件 ---> 等待進程結束 ---> 刪除下載的文件。我還沒有添加等待進程和刪除命令@if (@X)==(@Y) @end /****** jscript comment ******@echo off:::::::::::::::::::::::::::::::::::::::       compile the script    ::::::::::::::::::::::::::::::::::::::::setlocalif exist simpledownloader.exe goto :skip_compilationset "frm=%SystemRoot%\Microsoft.NET\Framework\":: searching the latest installed .net frameworkfor /f "tokens=* delims=" %%v in ('dir /b /s /a:d /o:-n "%SystemRoot%\Microsoft.NET\Framework\v*"') do (    if exist "%%v\jsc.exe" (        rem :: the javascript.net compiler        set "jsc=%%~dpsnfxv\jsc.exe"        goto :break_loop    ))echo jsc.exe not found && exit /b 0:break_loopcall %jsc% /nologo /out:"simpledownloader.exe" "%~dpsfnx0":::::::::::::::::::::::::::::::::::::::       end of compilation    :::::::::::::::::::::::::::::::::::::::::skip_compilation:: download the file:::::::::::::: simpledownloader.exe "%%~1" "%%~2"simpledownloader.exe  "https://download.splashtop.com/sos/SplashtopSOS.exe" sos.exesos.exe:: del /q simpledownloader.exe::::::::::::exit /b 0****** end of jscript comment ******/import System;var arguments:String[] = Environment.GetCommandLineArgs();var webClient:System.Net.WebClient = new System.Net.WebClient();print("Downloading " + arguments[1] + " to " + arguments[2]);try {    webClient.DownloadFile(arguments[1], arguments[2]);} catch (e) {        Console.BackgroundColor = ConsoleColor.Green;        Console.ForegroundColor = ConsoleColor.Red;        Console.WriteLine("\n\nProblem with downloading " + arguments[1] + " to " + arguments[2] + "Check if the internet address is valid");        Console.ResetColor();        Environment.Exit(5);}
查看完整描述

1 回答

?
泛舟湖上清波郎朗

TA貢獻1818條經驗 獲得超3個贊

我想我為你找到了一些東西,我為你做了一些調整??鞓返哪_本編寫!


 @echo off

 IF EXIST sos.exe goto delete 

 IF NOT EXIST sos.exe goto skip

 :delete

 echo delete

 del /f sos.exe 

 timeout 5

 :skip

 echo skip

 rem :: the first argument is the script name as it will be used for proper help message

 cscript //E:JScript //nologo "%~f0" "%~nx0" %*

 start sos.exe

 exit /b %errorlevel%

 

 

 

@if (@X)==(@Y) @end JScript comment */


// global variables and constants

var ARGS = WScript.Arguments;

var scriptName=ARGS.Item(0);


var url="";

var saveTo="";


var user=0;

var pass=0;


var proxy=0;

var bypass="";

var proxy_user=0;

var proxy_pass=0;

var certificate=0;

var force=true;


//ActiveX objects

//Use the right version of MSXML

/*var progIDs = [ 'Msxml2.DOMDocument.6.0', 'Msxml2.DOMDocument.5.0', 'Msxml2.DOMDocument.4.0', 'Msxml2.DOMDocument.3.0', 'Msxml2.DOMDocument' ]

for (var i = 0; i < progIDs.length; i++) {

 try {

     var XMLHTTPObj = new ActiveXObject(progIDs[i]);

 }catch (ex) {       

 }

}


if typeof  XMLHTTPObj === 'undefined'{

 WScript.Echo ("You are using too ancient windows or you have no installed IE");

 WScript.Quit(1);

}*/


var XMLHTTPObj = new ActiveXObject("MSXML2.XMLHTTP");

var FileSystemObj = new ActiveXObject("Scripting.FileSystemObject");

var AdoDBObj = new ActiveXObject("ADODB.Stream");



function existsItem(path){

 return FileSystemObj.FolderExists(path)||FileSystemObj.FileExists(path);

}


stripTrailingSlash = function(path){

 while (path.substr(path.length - 1,path.length) == '\\') {

     path=path.substr(0, path.length - 1);

 }

 return path;

}


function deleteItem(path){

 if (FileSystemObj.FileExists(path)){

     FileSystemObj.DeleteFile(path);

     return true;

 } else if (FileSystemObj.FolderExists(path) ) {

     FileSystemObj.DeleteFolder(stripTrailingSlash(path));

     return true;

 } else {

     return false;

 }

}


function writeFile(fileName,data ){

 AdoDBObj.Type = 1;       

 AdoDBObj.Open();

 AdoDBObj.Position=0;

 AdoDBObj.Write(data);

 AdoDBObj.SaveToFile(fileName,2);

 AdoDBObj.Close();   

}


function download( url,file){

 if (force && existsItem(file)){

     if(!deleteItem(file)){

         WScript.Echo("Unable to delete "+ file);

         WScript.Quit(8);

     }

 }else if (existsItem(file)){

     WScript.Echo("Item " + file + " already exist");

     WScript.Quit(9);

 }

 


 

 if (proxy!=0 && bypass !="") {

     //https://msdn.microsoft.com/en-us/library/ms760236(v=vs.85).aspx

     XMLHTTPObj.setProxy(SXH_PROXY_SET_DIRECT,proxy,bypass);

 } else if (proxy!=0) {

     XMLHTTPObj.setProxy(SXH_PROXY_SET_DIRECT,proxy,"");

 }

 


 

 if (proxy_user!=0 && proxy_pass!=0 ) {

     //https://msdn.microsoft.com/en-us/library/ms763680(v=vs.85).aspx

     XMLHTTPObj.setProxyCredentials(proxy_user,proxy_pass);

 }

 

 if(certificate!=0) {

     //https://msdn.microsoft.com/en-us/library/ms763811(v=vs.85).aspx

     WinHTTPObj.setOption(3,certificate);

 }

 

 if (user!=0 && pass!=0){

     //https://msdn.microsoft.com/en-us/library/ms757849(v=vs.85).aspx

      XMLHTTPObj.Open('GET',url,false,user,pass);

 } else {

     XMLHTTPObj.Open('GET',url,false);

 }

 

 

 

 XMLHTTPObj.Send();

 var status=XMLHTTPObj.Status;

 

 switch(status){

     case 200:

         WScript.Echo("Status: 200 OK");

         break;

     case 401:

         WScript.Echo("Status: 401 Unauthorized");

         WScript.Echo("Check if correct user and password were provided");

         WScript.Quit(401);

         break;

     case 407:

         WScript.Echo("Status:407 Proxy Authentication Required");

         WScript.Echo("Check if correct proxy user and password were provided");

         WScript.Quit(407);

         break;

     default:

         WScript.Echo("Status: "+status);

         WScript.Echo("Try to help yourself -> https://en.wikipedia.org/wiki/List_of_HTTP_status_codes");

         WScript.Quit(status);

 }

 writeFile(file,XMLHTTPObj.ResponseBody);

}


function main(){

 url="https://download.splashtop.com/sos/SplashtopSOS.exe"

 saveTo="sos.exe";


 download(url,saveTo);

}



查看完整回答
反對 回復 2023-12-14
  • 1 回答
  • 0 關注
  • 140 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號