Answer the question
In order to leave comments, you need to log in
Is it possible to upload a file through VBS script without disturbing Windows Defender?
I wrote a script that creates a folder on a PC and loads a document there, after which it automatically opens the folder for viewing. Everything is fine, the script works, BUT Windows Defender removes it as soon as it sees it.
Is there a solution to this problem?
Dim objFSO, objFolder, objShell, strDirectory
Set WshNetwork = WScript.CreateObject("WScript.Network")
'MsgBox WshNetwork.username
strDirectory = "C:\Users\" & WshNetwork.username & "\Downloads\Квалификация"
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FolderExists(strDirectory) Then
Set objFolder = objFSO.GetFolder(strDirectory)
Else
Set objFolder = objFSO.CreateFolder(strDirectory)
End If
Set oXMLHTTP = CreateObject("MSXML2.XMLHTTP")
oXMLHTTP.Open "GET", "https://site.ru/word.docx", 0
oXMLHTTP.Send
Set oADOStream = CreateObject("ADODB.Stream")
oADOStream.Mode = 3
oADOStream.Type = 1
oADOStream.Open
oADOStream.Write oXMLHTTP.responseBody
oADOStream.SaveToFile "C:\Users\" & WshNetwork.username & "\Downloads\Квалификация\Вордовский документ с сервера.docx", 2
Set objShell = CreateObject("Wscript.Shell")
objShell.Run strDirectory
Answer the question
In order to leave comments, you need to log in
I found a way, through a .bat file, you can open a link to download a document in the default browser and at the same time track the Downloads folder in the background in the loop , as soon as the file we expect appears in it, open Downloads in Explorer and select the file itself.
Example code for future generations:
@echo off
chcp 65001
if not exist "%Userprofile%\Downloads\word.docx" start "" "https://site.ru/word.docx"
cmd/c for /l %%i in () do @(if exist "%Userprofile%\Downloads\word.docx" explorer /select, "%Userprofile%\Downloads\word.docx"^& exit/b)^&^>nul timeout /t 1 /nobreak
exit
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question