Discussion:
[clamav-users] Batch file for Windows.
Jeff
2018-09-18 01:44:14 UTC
Permalink
Guys and Gals,



I've been unsuccessful in creating a working batch file. I've Googled and
searched the ClamAV list but only found one incomplete sample.



Can someone share a Windows batch file or PowerShell script that does the
following:



When ran, recursively scans a particular directory, moves any infected files
to another directory and emails an alert if a virus is detected. The email
alert should contain info about the infected file(s) including the path.



Keeping fingers crossed :-)



Thanks,



Jeff



--
Michael Da Cova
2018-09-18 07:10:40 UTC
Permalink
Hi Jeff

have you looked at clamwin? http://www.clamwin.com/


Michael
Post by Jeff
Guys and Gals,
I’ve been unsuccessful in creating  a working batch file. I’ve Googled
and searched the ClamAV list but only found one incomplete sample…
Can someone share a Windows batch file or PowerShell script that does
When ran, recursively scans a particular directory, moves any infected
files to another directory and emails an alert if a virus is detected.
The email alert should contain info about the infected file(s)
including the path.
Keeping fingers crossed :-)
Thanks,
Jeff
--
_______________________________________________
clamav-users mailing list
http://lists.clamav.net/cgi-bin/mailman/listinfo/clamav-users
https://github.com/vrtadmin/clamav-faq
http://www.clamav.net/contact.html#ml
Jeff
2018-09-18 11:52:26 UTC
Permalink
Michael,



Thanks for the suggestion.



I did look at ClamWin, a while back, but from what I remember, updates are
slow in coming. I'll take a another look at it. There was another reason why
I opted for ClamAV but I do not recall. Also, I already have ClamAV
installed, clamd running as a service, custom configured with extra
signatures and auto updating.



I want to use a batch file because I want my FTP server to trigger the scan,
automatically, when files are uploaded.



Below is all I have found for Windows:



.

@ECHO OFF

TITLE CLAMAV ANTIVIRUS SCANNER

SET /P scan=Please enter path to scan:

IF "%scan%"=="" GOTO Error

ECHO Scanning path: %scan%

ECHO Please wait for a moment...

cmd /c clamscan.exe -r -i "%scan%" --move=C:\ClamAV-x64\quarantine
--log=logs.txt

ECHO ----------------

GOTO End

:Error

ECHO You didn't enter path...

:End

PAUSE

.



How do I tweak the code above so that the command below is used if a virus
is found:



.

SwithMail.exe /s /x "SwithMailSettings.xml"

.



If I use SwitchMail, I can have it use logs.txt as the body of the email
alert.



Thanks,



Jeff



--



From: clamav-users [mailto:clamav-users-***@lists.clamav.net] On Behalf
Of Michael Da Cova
Sent: Tuesday, September 18, 2018 3:11 AM
To: clamav-***@lists.clamav.net
Subject: Re: [clamav-users] Batch file for Windows.



Hi Jeff

have you looked at clamwin? http://www.clamwin.com/


Michael

On 18/09/18 02:44, Jeff wrote:

Guys and Gals,



I've been unsuccessful in creating a working batch file. I've Googled and
searched the ClamAV list but only found one incomplete sample.



Can someone share a Windows batch file or PowerShell script that does the
following:



When ran, recursively scans a particular directory, moves any infected files
to another directory and emails an alert if a virus is detected. The email
alert should contain info about the infected file(s) including the path.



Keeping fingers crossed :-)



Thanks,



Jeff



--








_______________________________________________
clamav-users mailing list
clamav-***@lists.clamav.net
http://lists.clamav.net/cgi-bin/mailman/listinfo/clamav-users


Help us build a comprehensive ClamAV guide:
https://github.com/vrtadmin/clamav-faq

http://www.clamav.net/contact.html#ml
Thomas McCourt (tmccourt)
2018-09-18 15:29:58 UTC
Permalink
Does it have to be a batch file? Python could do it, fairly easily.

From: clamav-users <clamav-users-***@lists.clamav.net> on behalf of Jeff <***@gmail.com>
Reply-To: "***@gmail.com" <***@gmail.com>, ClamAV users ML <clamav-***@lists.clamav.net>
Date: Monday, September 17, 2018 at 9:44 PM
To: "clamav-***@lists.clamav.net" <clamav-***@lists.clamav.net>
Subject: [clamav-users] Batch file for Windows.

Guys and Gals,

I’ve been unsuccessful in creating a working batch file. I’ve Googled and searched the ClamAV list but only found one incomplete sample


Can someone share a Windows batch file or PowerShell script that does the following:

When ran, recursively scans a particular directory, moves any infected files to another directory and emails an alert if a virus is detected. The email alert should contain info about the infected file(s) including the path.

Keeping fingers crossed :-)

Thanks,

Jeff

--
G.W. Haywood
2018-09-18 17:39:17 UTC
Permalink
Hi there,
...
cmd /c clamscan.exe -r -i "%scan%" ...
...
How do I tweak the code above ...
However you tweak it, do please make sure that what you're doing does
not make things worse rather than better.

For example, where does "%scan%" come from? If it's from an untrusted
source such as a user-supplied file or pathname, you'd be well advised
to sanitize it carefully. Perhaps, also, even if it isn't. :)

If I were using a Linux box it would probably be 'clamdscan' (to send
the file to the clamd daemon, which already has the database loaded)
rather than 'clamscan' (which would probably take a minute or two to
load the database(s) before starting a scan). I know little about the
Windows versions of ClamAV, but from the very minimal research that I
just did I believe that much the same approach is possible.
--
73,
Ged.
_______________________________________________
clamav-users mailing list
clamav-***@lists.clamav.net
http://lists.clamav.net/cgi-bin/mailman/listinfo/clamav-users


Help us build a comprehensive ClamAV guide:
https://github.com/vrtadmin/clamav-faq

http://www.clamav.net/contact.html#ml
Loading...