Speak on remote computers script

General HouseBot discussion. Any issues that don't fit into any of the other topics belong here.
Post Reply
roussell
Advanced Member
Posts: 268
Joined: Wed Dec 15, 2004 9:07 am
Location: Pelham, AL

Speak on remote computers script

Post by roussell »

Attached is a script device that will let HouseBot speak on remote computers on your local network. It works by building and executing a VBscript on the remote copmuter (c:\HBSpeak.vbs) and deleting it when finished. Because of this, the HB server's user account will also have to exist on the remote computer and will need to be an administrator. If all of your PCs run as 'administrator' and all have the same password, then you're fine. Otherwise, you'll need to create matching usernames/passwords...

This script requires Microsoft's SAPI 5.1 on the speaking computer. The speaking voice can changed by changing the index of the 'Voice Index' property. You can discover the voices and corresponding index by running the included 'getVoices.vbs' script that was included with this script and installed in the config\scripts directory. Copy the 'getVoices.vbs' script to your remote (speaking) computer and run it to find out the index number of your installed voices.

This works well for having Swremotes speak warnings, announcements, etc... Despite the remote computer creating a file and executing it, the speed from when you execute the script on the server and the voice speaks on the remote pc is near-instant.

Enjoy,
Terry
Attachments
RemoteSpeak.hbx
(2.34 KiB) Downloaded 752 times
edgar
Member
Posts: 95
Joined: Tue Mar 24, 2009 11:14 pm
Location: Springfield, VA

Re: Speak on remote computers script

Post by edgar »

Hey Terry,

Thanks for the contribution! This is cool. I was wondering if you know which files I would need to make this work on a remote PC. Reason I ask is that I have a Wyse thin client with embedded XP and storage is VERY limited. I am thinking of getting off the flash drive and going with XP PRO but for the moment my SWRemote runs ok. I would love to leverage the onboard audio for the TTS. MS website shows the following files. Not sure which ones I MUST have to support this:

msttss22L.exe
2.0 MB

sapi.chm
2.3 MB

Sp5TTIntXP.exe
3.5 MB

SpeechSDK51.exe
68.0 MB

SpeechSDK51LangPack.exe
81.5 MB

SpeechSDK51MSM.exe
131.5 MB

Any help would be awesome! Thank you!

v/r

Kevin
roussell
Advanced Member
Posts: 268
Joined: Wed Dec 15, 2004 9:07 am
Location: Pelham, AL

Re: Speak on remote computers script

Post by roussell »

I think SpeechSDK51.exe (68Mb) is the one you need. Hopefully you have enough space. I was running XPe for a while but the image I had didn't have a script engine or web server so I went with regular XP. I think the SAPI I installed before that was the SpeechSDK51.exe file.

You can create a one-line .vbs script to test the install. Something like this should work once you get SAPI installed correctly.

Code: Select all

CreateObject("SAPI.SpVoice").speak "This is a Test"

Terry
edgar
Member
Posts: 95
Joined: Tue Mar 24, 2009 11:14 pm
Location: Springfield, VA

Re: Speak on remote computers script

Post by edgar »

Thanks Terry,

I will give it a go.

v/r

Kevin
ScottBot
Site Admin
Posts: 2790
Joined: Thu Feb 13, 2003 6:46 pm
Location: Georgia (USA)
Contact:

Re: Speak on remote computers script

Post by ScottBot »

Terry,

Thanks for sharing this script. Seems pretty useful and I was going to give it a try myself. However, I seem to be missing something.

When I run the script it creates the HBSpeak.vbs in the root of my C drive, but doesn't execute it. Eventually I get an error on the server pointing to line 37 saying "Error:0 The remote server machine does not exist or is unavailable: GetObject"

The machine is available and it had sufficient privileged to create the HBSpeak.vbs file, so it looks like there's something with it not being able to run the vbs remotely. My wscript.exe is found in my \windows\system32 directory. I can run the HBSpeak.vbs file from the remote machine and it speaks fine so the wscript and speech SDK is setup correctly. Maybe a permission somewhere I need to set?? I'm running Vista on both machines.
Scott
ScottBot
Site Admin
Posts: 2790
Joined: Thu Feb 13, 2003 6:46 pm
Location: Georgia (USA)
Contact:

Re: Speak on remote computers script

Post by ScottBot »

And the winmgmt service is running on both computers.
Scott
ScottBot
Site Admin
Posts: 2790
Joined: Thu Feb 13, 2003 6:46 pm
Location: Georgia (USA)
Contact:

Re: Speak on remote computers script

Post by ScottBot »

A little closer... I found that WMI was being blocked by my Windows firewall. I enabled WMI through the firewall and now the server script runs and stops quickly and the file is still created on the remote pc. However, it still doesn't speak. It also doesn't delete the file when finished, so I'm thinking it's still not executing.

I'll stop talking to myself now. Maybe this will ring a bell with you.
Scott
roussell
Advanced Member
Posts: 268
Joined: Wed Dec 15, 2004 9:07 am
Location: Pelham, AL

Re: Speak on remote computers script

Post by roussell »

I was going to say check the firewall, as I have mine turned off. I'm also running XP, not Vista so I'm not sure if there are differences there. I remember I was having similar problems when I was setting up the script but that was because of escaping quotes, proper number of parentheses, etc.

Edit RemoteSpeak.vbs and comment out (place a single quote in front of CreateObject) the delete line that looks like this:

Code: Select all

CreateObject(""Scripting.FileSystemObject"").DeleteFile (""C:\HBSpeak.vbs"")"
Run the script so it will create the remote .vbs file and then create the following .vbs on the server:

Code: Select all

remotetarget = "10.10.220.45"
b = GetObject("winmgmts:\\" & (RemoteTarget) & "\root\cimv2:Win32_Process").Create("C:\windows\system32\wscript.exe ""c:\HBSpeak.vbs""", null, null, intProcessID)
Replace the IP address in the example above with the IP of the pc with the HBSpeak.vbs and run the script. Let me know if that does anything...

All we're really doing with that second part is remotely executing an application. Make sure you have wscript.exe and that the path is correct on the remote Vista box. As I mentioned, I don't have Vista so can't test that. I guess it's also possible that Vista uses a different method for executing a file, if it's still allowed in the more "secure" OS :? .

I'll dig around some more and see if I can come up with something.

Terry
ScottBot
Site Admin
Posts: 2790
Joined: Thu Feb 13, 2003 6:46 pm
Location: Georgia (USA)
Contact:

Re: Speak on remote computers script

Post by ScottBot »

Running the script that just tries to run the script on the remote PC doesn't really seem to do much. It doesn't run the text-2-speech on the remote pc. I added a syntax error just to make sure it was running, and it is being executed.

I also remote all the sapi stuff from the remote script and just added a message box. Still nothing.
Scott
roussell
Advanced Member
Posts: 268
Joined: Wed Dec 15, 2004 9:07 am
Location: Pelham, AL

Re: Speak on remote computers script

Post by roussell »

Did you check your path to wscript.exe? The only way I can duplicate your problem is to enter a bogus path for wscript.exe in the script. Running the script then behaves as you describe - changing from running to stopped very quickly with no speech produced.

If your wscript.exe isn't in c:\windows\system32\wscript.exe then the script in HB will need to be changed to reflect it.

If the path is correct, does the username attempting to execute the script have the proper permissions to wscript.exe? I can change the parameter of the script so it requires a username/password to pass to the remote computer if you think that will help.

EDIT: Try replacing the contents of your RemoteSpeak.vb with the content below. I included more options that Vista may require and also broke out the wscript path stuff to make it a little more readable.

Code: Select all

' Author: Terry Roussell
' Language: VBScript
' Description: This HouseBot script will build a VBscript file on a remote computer (C:\HBSpeak.vbs), execute it
'              and speak the text that is entered into the 'Phrase' property.
'              This script requires Microsofts SAPI 5.1 on the speaking computer and administrator access to the
'              remote computer. 
'              The speaking voice can changed by changing the index of the 'Voice Index' property.
'              You can discover the voices and corresponding index by running the included 'getVoices.vbs' script
'              that was included with this script and installed in the config\scripts directory. Copy the
'              'getVoices.vbs' script to your remote (speaking) computer and run it to find out the index number
'              of your installed voices.
'==========================================================================================================================

Phrase       = GetPropertyValue("Remote Speak.Phrase")
RemoteTarget = GetPropertyValue("Remote Speak.Remote Target")
Volume       = GetPropertyValue("Remote Speak.Volume")
VoiceIndex   = GetPropertyValue("Remote Speak.Voice Index")
Rate         = GetPropertyValue("Remote Speak.Rate")
strCommand   = "C:\windows\system32\wscript.exe c:\HBSpeak.vbs"

A = "Set VObj = CreateObject(""SAPI.SpVoice"")" & VBCRLF & _
 "with VObj" & VBCRLF & _
     "Set .voice = .getvoices.item(" & (VoiceIndex) & ")" & VBCRLF & _
     ".Volume = " & """" & (Volume) & """" & VBCRLF & _
     ".Rate = " & """" & (Rate) & """" & VBCRLF & _
     ".speak " & """" & (Phrase) & """" & VBCRLF & _
"end with" & VBCRLF & _
 "    CreateObject(""Scripting.FileSystemObject"").DeleteFile (""C:\HBSpeak.vbs"")"


' Create the vbs on remote C$ - Requires admin access on the remote computer
CreateObject("Scripting.FileSystemObject").OpenTextFile("\\" & (RemoteTarget) & "\C$\HBSpeak.vbs",2,True).Write A

' Run the VBS through Wscript on remote machine via WMI Object Win32_Process
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" _
    & RemoteTarget & "\root\cimv2")

Set objStartup = objWMIService.Get("Win32_ProcessStartup")
Set objConfig = objStartup.SpawnInstance_
Set objProcess = objWMIService.Get("Win32_Process")
intReturn = objProcess.Create _
    (strCommand, Null, objConfig, intProcessID)
Terry
ScottBot
Site Admin
Posts: 2790
Joined: Thu Feb 13, 2003 6:46 pm
Location: Georgia (USA)
Contact:

Re: Speak on remote computers script

Post by ScottBot »

wscript is definitely in the correct location. If I run HBSpeak.vbs from the remote machine, it speaks fine, so that should verify the wscript location and the sapi setup is good.

I tried the new script and it has the same results.

I'm logged into both machines with the same admin username and password. The fact that it can create the HBSpeak.vbs file on the remote machine should verify that the account has some level of permission on the remote machine.

I'm guessing it's some kind of WMI security issue. If I changed the HBSpeak script to just display a message box, that didn't work either. So it's not wscript or sapi... it's just running the dang script remotely.
Scott
roussell
Advanced Member
Posts: 268
Joined: Wed Dec 15, 2004 9:07 am
Location: Pelham, AL

Re: Speak on remote computers script

Post by roussell »

After a lot of Googling, I ran across this:

http://msdn.microsoft.com/en-us/library ... _namespace

It looks like MS did tighten up the security for Vista as there are some specific steps to opening security on WMI namespaces.

Hope fully this will help, if it does, let me know the steps you took and I'll place them in the export for others with Vista.

Ya know, it might be easier to 'upgrade' to XP. 8)

Terry
ScottBot
Site Admin
Posts: 2790
Joined: Thu Feb 13, 2003 6:46 pm
Location: Georgia (USA)
Contact:

Re: Speak on remote computers script

Post by ScottBot »

The MSDN article was helpful, but still no luck. I'm guessing it's security related too, but I messed with about every setting I could find without success.

It's no big deal. I just thought it was a neat script that I could use, but I can live without it.
Ya know, it might be easier to 'upgrade' to XP.
The thought has crossed my mind before. But I've been mostly satisfied with Vista. Maybe Windows 7 will make the WMI security easier.
Scott
roussell
Advanced Member
Posts: 268
Joined: Wed Dec 15, 2004 9:07 am
Location: Pelham, AL

Re: Speak on remote computers script

Post by roussell »

If I can round up a copy of Vista to test with, I'll install it on a virtual and see if I can come up with anything. The problem is that I don't even know anyone that runs it so I can't hit up a friend or anything. I would like to find a solution though as I fear that Windows 7 will implement similar security and I've yet to find a decent solution for sending speech to a remote computer. I don't remember how long you get before you're forced to activate Vista post install, but maybe that will give me enough time.

Terry
roussell
Advanced Member
Posts: 268
Joined: Wed Dec 15, 2004 9:07 am
Location: Pelham, AL

Re: Speak on remote computers script

Post by roussell »

Ok, so I sourced a copy of Vista Ultimate and installed it in VMware Fusion on my MacBook; I'm now able to re-create your problem. I worked for SEVERAL hours last night reading through everything I could find on MSDN- I shut off UAC & Firewall, enabled remote admin access, dcom config, com security, workstation trust accounts, registry edits, blah, blah, blah. Then end result - nothing. Like you I can copy the file to the remote box, but it will never execute remotely. Microsoft's sample scripts don't either so I'm confident it isn't the code. I haven't given up, but clearly I need something other than google to help here. I'm going to hit up some of the developers at work to see if they have any idea. I hope things aren't this hard with Windows 7.

Potential Feature request: How difficult would it be to embed a SAPI hook into the swremotes? Maybe just a simple checkbox in the swremote config that would open a SAPI port - A matching device would need to exist that would be similar to my script device - pick a computer, key in a text phrase, and send it. The connection could be UDP to simplify things a bit and you could probably use your TCP send device with a little tweaking... If that doesn't interest you at the moment, I may have a go at writing something a a separate "HBspeaker" app and device using the .net wrapper. It won't be a huge priority though as we're busy preparing our house to sell and the script works beautifully for me in my XP world...

I will keep on digging to find an answer to the WMI security thing though...
Terry
Post Reply