Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > Scripting

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 03-26-2012, 06:20 PM
10tech 10tech is offline
Registered User
 
Join Date: Mar 2012
Posts: 20
LOGON - LOGOFF .WAV Sound

Perhaps this question has been asked before, but can someone give me an example of how to add a logon.wav or logoff.wav sound to the end of a Log ON and Log Off VBS script. Can the Windows imbedded logon and logoff.wav files be used?

Any help would be appreciated.

Thanks.
Tom
Reply With Quote
  #2  
Old 03-26-2012, 06:58 PM
miked's Avatar
miked miked is offline
Registered User
 
Join Date: Feb 2004
Posts: 2,040
The SecureCRT Scripting Manual has a solution which shows how to play .wav files. See Solution: Receive Notification when “Error-Indicating” Text Appears currently pp: 38-39. Can you adapt the example to your script?

Code:
' Attempt to connect...
' .
' . <Your code here... attempt to connect>
' .
          

' Check to see if we're connected.  If so, play sound
If Not crt.Session.Connected Then
  Set myShell = CreateObject("WScript.Shell")
  Set myFso = CreateObject("Scripting.FileSystemObject")
  myShell.Run "RunDll32.exe " & _
                    myFso.GetSpecialFolder(1) & "\msdxm.ocx,RunDll " & _
                    "/play /close C:\Windows\Media\Logon.wav"

End If

' Now loop forever waiting for disconnect
Do
    If Not crt.Session.Connected Then
    myShell.Run "RunDll32.exe " & _
                    myFso.GetSpecialFolder(1) & "\msdxm.ocx,RunDll " & _
                    "/play /close C:\Windows\Media\Logoff.wav"
    End If
Loop
Another possibility which I think seems better could be to enable the button bar (View menu / Button Bar) and map buttons to run the logon and logoff scripts. Doing this would allow you to run the script at logon, then exit the script. This would free up processor usage and allow you to run other scripts while connected.

Do either of the ideas above help?
__________________
Mike
VanDyke Software
Technical Support
[http://www.vandyke.com/support]
Reply With Quote
  #3  
Old 03-29-2012, 02:56 PM
10tech 10tech is offline
Registered User
 
Join Date: Mar 2012
Posts: 20
Thanks Michael, That is what I was looking for.

Tom.
Reply With Quote
  #4  
Old 03-29-2012, 04:39 PM
miked's Avatar
miked miked is offline
Registered User
 
Join Date: Feb 2004
Posts: 2,040
PlayWavSoundFileOrSpeakTextUsingSAPI.vbs

Glad to hear that helped! In case you're interested in more information about playing WAV files, the SecureCRT Scripting Manual is being updated and will contain updated information about using SAPI (the Speech API) to play a WAV file.

Also, I've attached an example VBScript, PlayWavSoundFileOrSpeakTextUsingSAPI.txt, which not only shows how to play a WAV file, but how to "speak" text either hard-coded, and also read from the crt.Screen.
Attached Files
File Type: txt PlayWavSoundFileOrSpeakTextUsingSAPI.txt (1.8 KB, 388 views)
__________________
Mike
VanDyke Software
Technical Support
[http://www.vandyke.com/support]
Reply With Quote
  #5  
Old 03-30-2012, 03:49 PM
10tech 10tech is offline
Registered User
 
Join Date: Mar 2012
Posts: 20
Thanks again Mike. I had to modify the location of the wave file in the original post to; "C:\WINNT\Media\notify.wav" since I'm using Windows XP. Also, When executing the RUN, Windows Media Player always popped up so I'm having to adjust the WAV to PLAY only and not also OPEN.

Tom
Reply With Quote
  #6  
Old 03-30-2012, 04:08 PM
miked's Avatar
miked miked is offline
Registered User
 
Join Date: Feb 2004
Posts: 2,040
Interesting - when I try it on XP I'm able to just run the script exactly as attached without modifying the paths or anything else. This surprising (to me) result helps show why examples can only be examples rather than custom fit for all. Examples may require a little tweak in order to do what's needed. Thanks for posting what you needed to do to get the script to work.
__________________
Mike
VanDyke Software
Technical Support
[http://www.vandyke.com/support]
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -6. The time now is 04:04 PM.