luca123 Posted August 8, 2015 Report Posted August 8, 2015 Dim args, numDim var1, var2Dim objFSO, objFolderDim objStreamDim WshShellDim strFolder, strURL, strFile, strFullDim strUnat, strCmdLine, strDmdLine'Sets and checks argumentsset args = WScript.Argumentsnum = args.CountIf num = 2 Then'URL for the filestrURL = args.Item(0)'Folder for the file to be downloaded tostrFolder = args.Item(1)ElseIf num = 3 ThenstrURL = args.Item(0)strFolder = args.item(1)strUnat = args.item(2)ElseWscript.Echo "Usage: \\servername\sharename\downrunsilent.vbe http://www.EXAMPLE.COM/EXECUTE.exe C:\temp"Wscript.Echo "For unattended options add them after download folder with a space and quotes."WScript.QuitEnd If'Converts URL to just filenamevar1 = Split(StrReverse(strURL), "/")var2 = StrReverse(var1(0))'Sets path for file downloadstrFile = var2strFull = strFolder & "\" & strFile'wscript.echo "File download location is: " & strFull'Verify local folder for file and creates it if doesn't existSet objFSO = CreateObject("Scripting.FileSystemObject")If objFSO.FolderExists(strFolder) ThenSet objFolder = objFSO.GetFolder(strFolder)Else'Wcript.Echo "Download folder does not exist."'Wscript.Echo "Creating download folder."Set objFolder = objFSO.CreateFolder(strFolder)End If' Sets up an ADO Stream to download fileSet objStream = CreateObject("ADODB.Stream")objStream.Type = 1 ' adTypeBinary' The following starts the downloadobjStream.Open ("URL=" & strURL)'wscript.echo "File downloaded"' This saves the file to the workstation in the folder specifiedobjStream.SaveToFile strFolder & "\" & strFile, 2 ' adSaveCreateOverWriteobjStream.CloseSet objStream = Nothing' Runs the downloaded file with or without unattended/silent optionsIf strUnat = "" Then'wscript.echo "Executing downloaded file"Set WshShell = CreateObject("WScript.Shell")WshShell.Run (chr(34) & strFull & chr(34))Set WsShell = NothingElse'WScript.echo "Executing downloaded file"Set WshShell = CreateObject("WScript.Shell")strCmdLine = strFull & " "strDmdLine = strCmdLine & strUnatWshShell.Run (strDmdLine)Set WsShell = NothingEnd If Quote
watsonAI Posted August 9, 2015 Report Posted August 9, 2015 Inainte sa spui "nimeni pe bune"(nimeni, pe bune?) incearca sa dai mai multe detalii, ce anume incerci sa faci, primesti vreo eroare. Observ ca incerci sa descarci un fisier, si sa executi niste comenzi in shell. Unde anume scriptul esueaza? Quote