Run a script remotely at a Windows Server

1

My situation is this. I want to have a script ran by pressing a button on my website (admin control page). My web server(linux) and dedicated box(windows 2012) are in different locations.


For example:

Web Server Page                |           Ded Server
                                            |
'Restart App' ------>------>---|-->->Script_To_Restart_App



The Windows 2012 server is not running windows webserver service IIS. I rather it not run it as it's not going to be running a webpage.

Is there anyway this is possible?

Thank You,

Clayton

Kirs Kringle

Posted 2014-08-12T22:23:54.840

Reputation: 244

Answers

1

What you're suggesting isn't trivial. There are a couple of approaches:

  1. Make your app running on the windows box listen for messages that tell it to restart. When it gets such a message, restart. There's several ways you can listen for such a message and you could choose the easiest one based on how you've built the app. E.g start listening on a known port and when you get a message that says 'restart' do it. This requires the ability to change the app, obviously. A variant on this is to build another app/service that just listens for restart messages and stops/starts the original app. That might be desired if you can't change your original app, or prefer not to.

  2. Use something in Windows to restart the app. There are built in ways (eg WMI) to restart services and probably to launch and stop processes. This is harder because you want to do it from a non-windows box. There's a great tool 'psexec' http://technet.microsoft.com/en-gb/sysinternals/bb897553.aspx that makes it really easy to do such things remotely, and there's a Linux version http://steronius.blogspot.co.uk/2013/05/psexec-via-linux.html so that might work out fine. This will require no programming but more messing with config and authentication ... perhaps, or it might just work immediately. You would call psexec from your php script with the necessary command line args to make it restart your windows app.

Rory

Posted 2014-08-12T22:23:54.840

Reputation: 1 473

I just want to execute from my webpage (PHP) to send a message to the windows server to run a script. – Kirs Kringle – 2014-08-12T22:53:21.650

Try the Linux version of psexec from the Linux command line and see if you can get it to work, ie run your script. If you can get it to work manually then you can call it from php. – Rory – 2014-08-12T22:57:54.017

Alright thank you Rory you have been great help! I will do research into this. – Kirs Kringle – 2014-08-12T22:58:48.123

-1

Have a look at winexe. It's a command line tool for Linux similar to the Windows tool psexec. Winexe remotely executes commands on Windows systems from Linux. Packages for winexe for several common Linux distributions are available from the openSUSE winexe package website.

Tom

Posted 2014-08-12T22:23:54.840

Reputation: 1

1

Have a look at How do I recommend software in my answers?

– Scott – 2014-08-12T23:35:46.680