0

I have been thinking about this subject for a while now, but this is my first attempt to get some help. So maybe I am still not asking the right questions, and I apologize for this. Btw, this is a "theorical" question, I am not asking for codes... AND, english is not my native language (sorry again)...

Well, I need to (programatically) create a method to allow a software inside a LAN (behind router/firewall) perform some action when a button in my website is clicked. The software is in a completely remote location, not in same computer/server as the website.

I know I could create some kind of thread in the software to periodically listen to a boolean database field, or maybe a text file in the website. But I think today we might have some better (more efficient) tecnology for this necessity...

I would like to know what is (or are) the most efficient solution(s) for this approach. By efficient I mean lightweight (do not overload my website with periodical requests) and fast (users need to wait just few seconds when click the button to get a response).

I appreciate any kind of thoughts and ideais about a possible solution for this necessity, and thanks in advance!

Guybrush
  • 1,575
  • 2
  • 27
  • 51

2 Answers2

0

Theoretically you could create a Stored Procedure on a SQL server, that is started as a result of the button click. For example the button click could increment a counter by querying the server then, as a result, run the procedure. You can even pass arguments into it. Within the stored procedure on the SQL server you would then tell it to run the program (preferably a service), using PowerShell.

Your button will call a stored procedure. This stored procedure will call 'xp_cmdshell' with parameters. Powershell will then tell remote computer to run application.

BUTTON > T-SQL Stored Procedure > xp_cmdshell (PowerShell) > Remotely Start Executable.

  • Hi @JayHamilton! Ok, I understood your point, but the software is not in same computer/server. It is my mistake, I updated this info in the question. Thanks! – Guybrush Dec 07 '16 at 00:32
  • Jay Hamilton please can you give me more details ? How can powershell commands would help me? Thanks! – Guybrush Dec 09 '16 at 00:37
  • See the following article. For more articles, i just googled 'powershell remote command exe' – Jay Hamilton Dec 09 '16 at 19:59
  • http://www.tomsitpro.com/articles/powershell-remotely-invoke-applications,2-41.html This explains how to send an application invocation to a network computer from your server. Look up how to issue powershell commands in SQL server and you'll be set ;) – Jay Hamilton Dec 09 '16 at 20:00
  • Ultimately the flow of events works as follows BUTTON > T-SQL STORED PROCEDURE > POWERSHELL (xp_cmdshell) > REMOTELY START EXE. – Jay Hamilton Dec 09 '16 at 20:04
0

First...you have an uphill struggle since doing what you want is VERY DANGEROUS and typically not allowed, since the point of a web app is to disengage from the hosting OS. Otherwise, hackers would have a huge front door into peoples machines.

Second...you're not clear on where the 'software' is located. Will it be executed on the web server that is hosing your web site, is it on a completely remote computer on the LAN, or is it to pull the exe back and execute on you're machine that happens to be on the LAN?

With that...you can check out these links for some guidance:

https://community.serif.com/forum/8612/x7-run-exe-eg-notepad-exe-by-clicking-button-in-website

How to launch an EXE from Web page (asp.net)

Finally, you might be able to use the website button to call into a web api that will execute the exe.

Community
  • 1
  • 1
  • The software is located on a completely remote computer, in a LAN, behide the router/firewall. I will check the links. Thank you! – Guybrush Dec 06 '16 at 21:01
  • I would say web app -> web api -> execute app on some machine (local or remote). You will need to ensure the web api machine has access to the app machine (if its local to web api machine, no problem. if not, you need permissions to the remote app machine). – Jon Spencer Dec 07 '16 at 22:35