OregonITFella
IS-IT--Management
I need some help with a little project I dreamed up (gotta love those). I want a login script to check each users machine that logs in and see if a particular application exists on the machine, and then emails me the machine name, username and if the application is installed or not. Can anyone start me out with some code to get me going? Below is what I have that I would like to use.
Code:
'=====================================
Dim oName, oUserName, ODomain, oMyIP, oTo
' Get the computer name
Set WshNetwork = CreateObject("WScript.Network")
oName = WshNetwork.ComputerName
' Get the username
Set WshNetwork = CreateObject("WScript.Network")
oUserName = WshNetwork.Username
' Set the company specific information
' Company Internet Domain Name
ODomain = "xxxxx.xxx"
' Set the SMTP server IP
oMyIP = "xxx.xxx.xxx.xxx"
' Where do you want the message to be delivered
oTo = "xxx@xxxxx.xxx"
' Set the visual basic constants as they do not exist within VBScript.
' Do Not set your smtp server information here.
Const cdoSendUsingMethod = "[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/sendusing",[/URL] _
cdoSendUsingPort = 2, _
cdoSMTPServer = "[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpserver"[/URL]
'// Create the CDO connections.
Dim iMsg, iConf, Flds
Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")
Set Flds = iConf.Fields
'// SMTP server configuration.
With Flds
.Item(cdoSendUsingMethod) = cdoSendUsingPort
'// Set the SMTP server address here.
.Item(cdoSMTPServer) = oMyIP
.Update
End With
'// Set the message properties.
With iMsg
Set .Configuration = iConf
.To = oTo
.From = oName & "@" & oDomain
.Subject = "Username and Machine Name"
.TextBody = "Machine " & oName & " at company " & ODomain & " is being used by " & oUsername
End With
'// An attachment can be included.
'iMsg.AddAttachment Attachment
'Send the message.
iMsg.Send
MsgBox "Done"