Embedded Automation Forum  

Go Back   Embedded Automation Forum > mHome Products > mControl Application Notes
Forums FAQ Members List Calendar Search Today's Posts Mark Forums Read

mControl Application Notes Application Notes, Tips & Tricks

Thread Tools Display Modes
Old 05-17-2008, 12:13 AM
Ted Singh's Avatar
Ted Singh Ted Singh is offline
Senior Member
Site Admin
Join Date: Nov 2005
Posts: 1,108
Default HOW TO: Run External Applications

The following post explains how you can use mControl to launch external applications as part of a macro action. It also explains the limitations to doing so - and possible workarounds.

1. Allow the mControl service to interact with the desktop
Since mControl runs as a service, to allow mControl to interact with the desktop, you must use Control Panel's Administrative Tools to configure Services. Find the "mHome Automation Server", select Properties and the Log On tab - and then enable the "Allow service to interact with the desktop".

2. Allow mControl to run external applications
Since running external applications can be a security risk, by default, mControl disables this functionality. To enable this functionality, use the mControl Service Manager, navigate to the AppSettings tab and enable the "Enable Run" feature. (Don't forget to Save and Apply - which I did when I was trying to get this working)

3. Write a macro that has a Run Application action
The toughest part of this step is getting the drive/path location of the application and the associated parameters right.

Here are a couple of tips that I used to get a song playing on Media Player:
- I googled "Windows Media Player" command line parameters - to learn just exactly how I would need to get media player to play my song
- I right-clicked on Windows Media Player and my song to get the drive/path/file information.
- I then opened a command line session and tested to see if the information gathered worked. Of course, at the command prompt level, you need to enclose the drive/path/file names within quotations. These quotations are not necessary in mControl
- Then I copied this information to the mControl "Run Application" dialog box

Limitations on Vista
This mechanism should work with no issues on pre-Vista platforms (i.e., XP, MCE2005).

Vista, however, has changed how services can interact with the desktop, so the experience is different, and depending on what you want to do, could render the experience unusable, though not dangerous. For security reasons, Vista now runs services (like mControl) in a different session. If you're interested, this is a good place to learn about this: http://www.kwakkelflap.com/blog/2007...n-windows.html.

Essentially, what will happen if you run the Run Application action on Vista, will alert you of user interface activity within the services' session:

You can look at this session by selecting the "Show me the message" option. You'll then flip over to the user interface on the services session and see your application running there:

For things that require limited user interaction (e.g., playing music or an automatic file management utility), the "Run Application" action can still do what want.

However, if you need some sort of user interaction, mControl's current implementation of the "Run Application" macro action may not be the right solution. Alternatives solutions for Vista include:
- Our new Vista Media Center controller provides powerful media control functionality - and we plan to expand this over time
- Write your own driver, which cues off some mControl event and then does what you need

Last edited by Ted Singh; 05-17-2008 at 12:22 AM. Reason: Formatting; Vista alternatives
Reply With Quote
Old 05-17-2008, 01:30 PM
groovejumper groovejumper is offline
Join Date: Apr 2008
Posts: 47

I discovered a way to have mControl on Vista run applications in user sessions without using the VMC controller or a custom driver. You can download pstools from the Windows Sysinternals site, extract psexec.exe and place it somewhere in your path (for example, in c:\windows\system32).

In your macro "Run Application" action, set the "Application" field to psexec.exe, and set the parameters to -i 1 [command line for your app].

The -i 1 is a switch that causes the application to run in session 1 (which is the first logged-in session, for us our main VMC machine is always logged in, so applications run this way appear on the screen without having to switch to another session or any additional windows popups). If you're running a VMC app (HTML or MCML) you can also cause it to run on an extender - the first extender uses session 2, the second uses session 3, and so on. So change -i 1 to -i 2.

For example, here's how my macro action starts the mControl MCML interface on our VMC machine:

Application: psexec.exe
Parameters: -i 1 c:\windows\ehome\ehshell.exe /entrypoint:{aebf238a-a1c5-4354-ba23-e693cb9f219e}\{3de6904a-d9c7-4ef9-b77d-c1216b39161e}

We can also start it as a macro action on the extender by using the same parameters except changing the -i 1 to -i 2.

Reply With Quote
Old 02-24-2009, 11:59 AM
martijn martijn is offline
Junior Member
Join Date: Nov 2008
Posts: 22
Question How do I: run an external vbscript


I'm running mControl on WHS.

When I try to run an app (in this case a vbscript) it does not seem to work so I did some testing.

To check if this feature is working at all, I entered calc.exe in the program field and no params. When I run the macro I see an new process (that runs in the system context) called calc.exe. Even though I allowed it to 'interact with desktop' it does not but the process calc.exe is there, launched under in the context of the SYSTEM user.

I replace the calc.exe with my helloworld.vbs script:

Set WshShell = WScript.CreateObject("WScript.Shell")
new_status = "hello"
WScript.Echo new_status
set WshShell = nothing

When I run this script under the administrator context by clicking on it, it will display a popup on the console with the word "hello" but when I use mControl it does not seem to work. (i.e. no popup)

I have replaced the pogram param with WSCRIPT.EXE and added the helloworld.vbs script as a parameter. This does not work either.

MY QUESTION: What is the correct way to call a .vbs script from mControl. Should I use:
A: the .VBS file in the program field, any params in the parameter field.
B: enter wscript.exe as the program, the script and the params go in the parameter field.
Personally I think it is answer B but can someone confirm this?

MY SECOND QUESTION: It looks as if the external programs all run as SYSTEM. Is there are way to make it use another UserID like Administrator an account created for running the external scripts?

(like when you schedule an application using windows task-scheduler, you can specify the userID it runs under as long as you provide those credentials when setting up the task)

OK. Please let me know. There is not much activity on this forum so I hope Ted or one of the other senior members will be able to pick-up on this post.
Reply With Quote

Thread Tools
Display Modes

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. The time now is 04:15 AM.

Powered by vBulletin® Version 3.8.3
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.