N
N
Nadim Zakirov2020-05-25 05:58:27
VBScript
Nadim Zakirov, 2020-05-25 05:58:27

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

1 answer(s)
N
Nadim Zakirov, 2020-05-25
@zkrvndm

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

Of course, the link and file name must be replaced with your own. The .bat file must be UTF-8 encoded !

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question