Hi All,
i want my virus scanner to run an exe after completeing some tasks, it has the capacity to do this.
what i want is a program that will pick up the user name and mail a simple message, 'done', to my mail account. i am struggeling to find out how to do this, can anyone suggest a program, a language or batch file line to acheve this. i am not a programer, but not inexperianced eather. any lines of code would be helpfull

cheers

spikes

Dani AI

Generated

A short, practical add-on that complements the replies from and : a tiny, dependency-free VBScript can send a one-line "done" notice and include the username and machine name. This avoids requiring a compiled helper or a full development environment and works on Win2K/XP-era clients. Common pitfalls to watch for are SMTP host/port/auth settings, outbound SMTP being blocked by policy, and the scanner running the post-action under a service account (which will change the reported username).

' postupdate.vbs - send a short "done" email with user+machine (CDO)
On Error Resume Next

Set net = CreateObject("WScript.Network")
user = net.UserName
comp = net.ComputerName

Set msg = CreateObject("CDO.Message")
msg.Subject = "Update complete: " & comp
msg.From = "scanner@example.com"
msg.To = "admin@example.com"
msg.TextBody = user & " on " & comp & " - update completed at " & Now

Set cfg = msg.Configuration
Set fld = cfg.Fields
fld.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
fld.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.server.com"
fld.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
' If auth required:
' fld.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
' fld.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "smtpuser"
' fld.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "smtppass"
' If SSL:
' fld.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
fld.Update

msg.Send

If Err.Number <> 0 Then
  Set fso = CreateObject("Scripting.FileSystemObject")
  Set f = fso.OpenTextFile("C:\logs\postupdate_error.log", 8, True)
  f.WriteLine Now & " - Error " & Err.Number & " - " & Err.Description
  f.Close
End If

Integration and troubleshooting notes: configure the scanner's post-update action to run the script via the Windows Script Host (for example, cscript //nologo C:\scripts\postupdate.vbs). Verify the account that runs the action — if it runs as the SYSTEM/service account the username value will reflect that account, so include computer name and timestamp in the message for reliable identification. If mail does not send, check SMTP host name, port (25/587/465), required authentication/SSL, local firewall/ISP blocks, and test TCP connectivity (telnet to the SMTP port or run the script interactively).

If per-client SMTP/auth is problematic, a more robust pattern is central logging: have the post-update action append a one-line record (timestamp, machine, user, status) to a secured UNC share. A server-side scheduled task can aggregate those records and send a digest. Also avoid embedding plaintext credentials in scripts — protect files with strict ACLs or use a relay that accepts IP-based or internal authentication. Compiled utilities like the one posted earlier by are convenient, but the same network and security considerations still apply.

Recommended Answers

All 12 Replies

I've never done anything like this via windows before. My guess, however, is that you would need some form of mail or SMTP server (perhaps the one built-into IIS?) What VirusScan program are you using?

using NAI enterprise virus scanner 7.0, it will allow you to enter the name of a program that you wish to run after a successfull update, i just want to know which of my users have updated and which havent.

spikes

I'm writing the program now... :-)

Okay, I'm done. The program can be downloaded here:

The only thing it requires the .NET Framework v1.1 (free download at Microsoft.com).

The ZIP file has 3 files in it: Emailer.exe, EmailerSettings.exe, and settings.config. To use emailer, extract it anywhere on your hard drive, and run EmailerSettings.exe. The Settings app will read the config file, and show you the settings. Adjust the settings for your needs. Below is an image of the settings app:

[img][/img]

Next, set the virus scanner to execute Emailer.exe. When the virus scan finishes, emailer.exe will read the settings, send the email, and exit. It looks like this while sending the email:

[img][/img]

I hope this is what you wanted :-).

Also, if Mr Gates (the TTF User) sees this, I will be releasing the VB.NET Source Code later today.

When ya get a chance, reply and tell me if this is what you needed.

I just want some satisfaction 8) .

Hi there,
Thank you so much for your help on this, but unfortuneatlywhen it ran it genarated the following:

application has generated an exception that could not be handled

process id = 0x754 (1876), thread id =0x74c (1868)

any ideas?

this was run on a win2k machine with the .NET framework in place

cheers

spikes

Is it the .NET Framework 1.1? It has just recently came out, try doing a windows update, it will appear in the reccomended updates.

Here is also a direct link for it:

Hi,
I've installed the exe for .NET 1.1 that you gave me the link for and unfortuneatly the exception is still there.

Is there anything i can do to help solve this?, or is there another way of codeing the program.

cheers

spikes

I have updated the original zip file with a new emailer.exe file that will tell you the error when it occurs. It can be downloaded here:

The problem that you are having is most likely to do with your SMTP Server. Either it doesn't exist, or it can't be properly connected.

What STMP server address are you using?

Hi,
Sorry it was just me being an idiot, it was the smtp address that i had enterd wrong. the mailer works a treat. thankyou for you hard work.

also, what software do you need to write programs useing the .NET framework, is it just the sdk from microsoft, and if so is it hard to learn the language?

again many thanks

spikes

Well, you don't need any software, just a text editor and the SDK to compile apps, but this is often very unrealistic. In actuality, you need a development enviornment, Visual Studio .NET 2003, which runs for about $500-$5000, depending on the version you want.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.