Domanda

I have a Windows game server (Mount & Blade: Warband) that I am trying to control remotely through a Rails application. I found a way to send text to the game server using Windows Script Hosting as follows:

Set ArgObj = WScript.Arguments
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.AppActivate "mb_warband_dedicated"

For lcv = 0 to ArgObj.Count - 1
    WshShell.SendKeys ArgObj(lcv)
    WshShell.SendKeys "{Enter}"
Next
WshShell.SendKeys "start"
WshShell.SendKeys "{Enter}"

While this feels fragile, it does seem to work when I try it on my local machine; it successfully shifts focus to the game server, sends its arguments as text to the game server, and starts the game.

My train of thought was to have my Rails app call the WSH executable when game commands are POSTed (using proper Rails authentication and authorization for security). This works if I'm Remote Desktop'ed into the remote machine running Rails and the game server, but as soon as I disconnect my Remote Desktop session, it doesn't work anymore. The Rails server receives the request, calls the script, but then I'm guessing the 'AppActivate' command can't find the window.

If it was a Linux machine I think I could use a named pipe. Any ideas here? Powershell? Maybe TCL? I could kill the game server process, edit the config, and then restart the game server, but everyone would be disconnected.

È stato utile?

Soluzione

If the Rails server runs as a Windows service, you may be running into Session 0 Isolation issues with interactive applications.

See: http://blogs.technet.com/b/voy/archive/2007/02/23/services-isolation-in-session-0-of-windows-vista-and-longhorn-server.aspx

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top