• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 556
  • Last Modified:

Script to send an email and play a sound on a remote PC..

I have a PC hooked up to our intercom system and I am able to play wav files on it that go over the PA system.

 What I am looking to do is have a VBscript on an employee's PC that can play a sound file on the PA PC and also send an email.

I have this so far to play the sound and it works.

psexec \\telcommudi sndrec32 /play /close c:\supervisor.wav
0
victordr
Asked:
victordr
  • 8
  • 8
1 Solution
 
victordrAuthor Commented:
So i have came across this and it works, but how would i put the two together?

25objEmail.Configuration.Fields.UpdateobjEmail.Send
Set objEmail = CreateObject("CDO.Message")objEmail.From = "myaddress@somewhere.com"objEmail.To = "myaddress@somewhere.com"objEmail.Subject = "Secuity Report for " & strServerName objEmail.Textbody = "Server Secutirity Report for" & strServerName & vbCRL & strBodyReportobjEmail.AddAttachment = strFilenameobjEmail.Configuration.Fields.Item _    ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2objEmail.Configuration.Fields.Item _    ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = _        "10.190.12.128" 'Modify to your SMTP Server AddressobjEmail.Configuration.Fields.Item _    ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25objEmail.Configuration.Fields.UpdateobjEmail.Send

Open in new window

0
 
Steve KnightIT ConsultancyCommented:
I'm not sure I know what you want to fo with this email (I cant see the code snippet for som reason on phone today?).

This is to run on the employees pc right, not the pa one, and how is it related.... A broadcast message sent at the same time, or a copy of the wav file that they send?

Do they need to be able to select the wav file to send too or is that c:\supervisor.wav etc. A fixed file already on the pa box?

I would use blat or cdo with short vbscript called from you batch but need to know what is to be sent pls.

Steve
0
 
Steve KnightIT ConsultancyCommented:
If you just want to run both from the same batch:

Take the sendmail.vbs into the same dir as your batch file.
Edit it in notepad to point to the right smtp server, subject, to and from addresses
In your batch file do:

@echo off
psexec \\telcommudi sndrec32 /play /close c:\supervisor.wav
if errorlevel 1  echo There seems to have been a problem playing the sounds -- but then you didn't hear it so should know...
cscript.exe //nologo sendmail.vbs

If you want it to send something specific related to the sound played etc. let me know and we can send that into the file from the command line etc.

Some emailing from batch scripts of mine:
http://scripts.dragon-it.co.uk/links/email-from-batch sendmail.vbs
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
victordrAuthor Commented:
I need to have a script located on all managers PC's desktop. I need it to play a sound on a remote PC(THe PA PC) and send an email from there PC.

 Is there a way to convert a VBS or BAT to an exe so they can't edit it?
0
 
Steve KnightIT ConsultancyCommented:
Not easily.  You could compile a program in something like VB, just mark the programs read only or put them on a read only file share for them to run?

You could use AutoIt or similar to write a program and then have that compiled into an EXE too.

0
 
victordrAuthor Commented:
Are you familar with AutoIT?
0
 
Steve KnightIT ConsultancyCommented:
Yes in p[revious versions, haven't looked at it for a while though.  Is great for scripting mainly other apps but you can have it compile into exe.  Not sure if we could have it do your jobs without calling psexec and the like anyway but worth looking at, will look myself if I have time.

Would suggest you could always hide and read only the batch / vbs files mind, and/or change ntfs permissions so they can't change / sack people if they do :-)
0
 
victordrAuthor Commented:
I have already figured out the email sending part, but just need to call PSEXEC.
0
 
Steve KnightIT ConsultancyCommented:
You should be able to use RunWait, i.e.

RunWait ("psexec \\telcommudi sndrec32 /play /close c:\supervisor.wav")

Is that what you mean?
If psexec is not installed on that machine you should copy it to the same dir as the auto it compiled prog and/or specify it in the prog, i.e.

RunWait ("\\server\share\psexec \\telcommudi sndrec32 /play /close c:\supervisor.wav")


0
 
victordrAuthor Commented:
This is what i have.  I would like to add a pop up box to let them know the message has played on the PA PC also.

#include <INet.au3>

$s_SmtpServer = "mail1"
$s_FromName = "Ealert
$s_FromAddress = "ealert@domain.com"
$s_ToAddress = "ealert@domain.com"
$s_Subject = "********* EMERGENCY ALERT *********"
Dim $as_Body[2]
$as_Body[0] = "Attention all employees. An emergency has taken place that requires evacuation of the building,"
$as_Body[1] = "please proceed in an orderly  fashion to the safest exit. Thank you"
$Response = _INetSmtpMail ($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body, @ComputerName, -1);
$err = @error
If $Response = 1 Then
    MsgBox(0, "The Emergency Alerts ", "Mail sent")
Else
    MsgBox(0, "Error!", "Mail failed with error code " & $err)
EndIf
RunWait ("psexec \\PAPC sndrec32 /play /close c:\supervisor.wav")

Open in new window

0
 
victordrAuthor Commented:
I am wondering if i can compile PSEXEC into the file?
0
 
Steve KnightIT ConsultancyCommented:
Not that I know of sorry!

Steve
0
 
victordrAuthor Commented:
I guess i can just copy psexec to all of the PC's \system32
0
 
Steve KnightIT ConsultancyCommented:
yes or just run it from fileshare like i suggested above?
0
 
TheGorbyCommented:
You can use the FileInstall() function to include psexec in the compiled exe. That allows you to have the exe place a copy of the file on the hard drive. But since your script is network dependant anyway, dragon-it's method is just as easy.
0
 
victordrAuthor Commented:
I ended up using Autoit and this was the correct answer.
0
 
Steve KnightIT ConsultancyCommented:
Glad it helped, is a great tool for things like this!

Steve
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 8
  • 8
Tackle projects and never again get stuck behind a technical roadblock.
Join Now