I wanted to be able to run a script on a remote computer over the local network. This example is so that I can mute the sound on the PC on the computer upstairs from the laptop downstairs. Until now I used VNC to do it. Thought I'd share it in case anyone wanted to do anything similar.
I managed to do it by installing a web server on the PC upstairs. Sounds a bit like overkill, but there is a great free server available at
http://www.aprelium.com/abyssws/index.html
which is small and easy to manage. I had to go into the advanced configuration and set enable SSI and set the parameter to allow Exec Cmd Execution.
I created a simple web page called index.shtml in the html folder where the server installed itself
Code:
<!-- #exec cmd="mute.exe" -->
<!-- #exec cmd="type temp.txt" -->
which means that whenever this page is requested, the server will run mute.exe, then display in contents of the file temp.txt
The AHK bit is then easy. On the remote PC in the same folder I created a simple script called mute.ahk and complited it
Code:
filedelete, temp.txt
SoundGet, master_mute, , mute
fileappend, was %master_mute%`n, temp.txt
SoundSet, +1, , mute
SoundGet, master_mute, , mute
fileappend, now %master_mute%, temp.txt
This just toggles the mute and puts whe result in the text file. Then all you need is something to call it from the other PC
Code:
FileDelete, down.html
URLDownloadToFile, http://192.168.0.3/index.shtml, down.html
FileRead, Result, down.html
msgbox, %result%
or of course just type
http://192.168.0.3/index.shtml in a browser. (192.168.0.3 is just the ip address of the host computer on the network).
In theory you could use something similar to run scripts over the internet. You need to be careful though, by enabling ssi command execution could allow someone to run commands on the server.
If anyone has a simpler solution I would like to know. I tried just running programs over a shared drive but could not get it to work.
Mike