basically, I am needing to execute a program on the viewers computer through a website. This program must be capable of talking to device drivers however, which makes it an unlikely candidate for activex. The website will only be used by clients(as in, it's not a public site) so having to change security settings isn't too big of a deal.
Also, we could possibly have them install an application on their computer, and then when they click a button on the website this activex control just executes the application they already installed to avoid device driver problems..
Does anyone have any ideas on how to do this well? I have a feeling activex won't just let you arbitrarily execute local applications. Also, it is preferred to be possible to do without certificates and signing(though it will eventually be over https)
(it's only tagged C# because that's the programming language to be used on both the client and server)
If you only need to tell the application to simply launch or launch with certain data, you can look into registering a protocol handler and create links, that the user can click, similar to myapp://the/data/you/need/to/send.
It sounds like you will have control over the client and server sides, so why not use WCF and set up the client application to connect to the server via a duplexed communication. On the server side keep a list of the clients that have connected to it and then when you need to trigger the client side code it will iterate over the list of clients and send the message to execute the code. And when the client disconnects it will be unregistered from the server.
See this link for more information on the duplex services.
Also, we could possibly have them install an application on their computer, and then when they click a button on the website this activex control just executes the application they already installed to avoid device driver problems..
Ding ding. That's pretty much what you'll have to do.
Related
I would like to know if there is a technique or solution for the follow problem.
I have a software application that is currently running inside of a Microsoft RDP session. I have some help resources built into it in which some of them open up on a webbrowser. Some of them are YouTube videos. The problem is taht through organisational policies, they cannot open YouTube clips within the RDP which connects to a interstate server.
What I would like to do is instead open up a webpage outside of that RDP connection on the local host computer instead, which does not have any restrictions like opening up YouTube webpage to play video clips.
Can you please suggest a technique, utility or solution to this problem?
Thanks,
Colin.
The nicest way to do this would probably be to create a dynamic virtual channel plugin for RDP: https://msdn.microsoft.com/en-us/library/bb540859(v=vs.85).aspx
You would have a server-side component registered to handle the protocols (http/https, I assume) you want to redirect back to the client, possibly with some filtering logic if you still want a few to run server-side (such as intranet sites); then a client-side mstsc plugin whose only job is to call ShellExecute on the URLs you pass back.
Piggybacking on clipboard redirection might be less code, but it obviously has side-effects - e.g it obliterates anything else the user might have had on the clipboard.
I want to run an exe on client system from my c# asp.net website. When I use Process.Start()
it throws an error:
The requested operation requires elevation.
How do I set permissions to run that exe?
You can't spawn processes on the client machine from server-side code.
When you use Process.Start in server-side code, it is attempting to execute the process there, on the server where the website is hosted. If you wanted to create processes on the clients computer then you would need to expose a download for them (and not in employing subterfuge, like malign sites might do to install software - supply it gracefully, and normally (and with permission)), or a Silverlight application or something along those lines.
The bottom line is that the code you want to execute (even if that is just to spawn a process) must reside on the client, and be executed there.
You can't run an application from a web server like that. You will have to have the user download the application by supplying the EXE, a setup file or using ClickOnce.
Or you can develop an ActiveX control that you can have the browser automatically download from a Trusted Internet Zone.
Once downloaded, proper signing with a certificate (signed from the trusted (corporate) root certificate) will avoid the user getting a prompt to ask whether he wishes to allow the ActiveX control to install/be activated -
The ActiveX control can subsequently do anything the interactively logged on user could. This means that to actually install a program you'd need to elevate (UAC on Vista+); But if the goal was just to run a standalone executable, you should be good to go.
This all assumes white-hat purposes in a (larger) corporate setting, because it relies on PKI infrastructure and central browser policies, to name just two.**
This would, really, lead to some excellent questions on serverfault or superuser
I noticed you said you wanted to run an exe file on the client, but you didn't say explicitly that the exe is on the server and you want to push it to the client. Everyone seems to be assuming that is the case.
You CAN accomplish this fairly easily with a small JavaScript if you have a few prerequisites:
The executable is already present on the client machine.
All of your clients are running IE
You can enforce a policy to put your site in the Intranet or Trusted
Sites zone.
So basically this means it's a corporate intranet application. I am assuming this is probably the case since, well, if you were expecting to do this with a public app, I would be surprised.
For the script to accomplish this, please see my answer to this question:
How can I get a program on a client machine to run from an ASP.NET page?
I'm currently working on an ASP.Net MVC4 application to automate a production workflow.
my client would prefer the solution to be "zero footprint", so completely running in browser.
One of the issues I can't imagine how to handle is to get data from a weighing scale connected to the client's serial/parallel port from within the page.
(Obviously this can't be done from the web backend ... )
I've been digging around, assuming this could be possible through javascript/jquery, but since this is running sandboxed within the browser, I'm assuming to get stuck that way ...
One of the approaches I considered was writing a self-hosted WCF webservice to run on the client that has the scale attached (hosted by a windows service or console app or so) that exposes the scale readout. Theoretically, that would allow me to consume the webservice in the IIS backend in my MVC C# code and serve it back to the client.
The only issue with this approach is that this would require the application to be hosted locally, where we'd prefer to have it hosted by an external provider.
Is there no way to handle this on the client side exclusively?
I can't imagine I'm the first person running into this, but I can't seem to find what I'm looking for by digging around on the web ...
Any thoughts ?
Thanks in advance! Stijn, Belgium
You absolutely must have a process running on the system that has access to hardware to support reading from any hardware interface. You have a lot of options there- it could be a local service running that can read the serial port and expose a simple HTTP endpoint to the browser. You can also do ActiveX-style controls for IE or browser extensions for Chrome:
http://developer.chrome.com/apps/app_usb.html
Just as a follow-up:
I ended up creating a user-control that reads out the COM-port through PInvoke of CreateFile to open the COM-port ...
Works great, no hassle with an external process running on the client etc ...
Does require full trust in the browser, but that's acceptable, since it'll run on clients under our control ...
grtz,
Stijn
I'm developing a little application which will connect to a remote machine, and return to the client a list of the remote's desktop icons.
I currently have this functionality working for local desktop icons.
In theory, I would assume I'd have to give the remote server the code I used to get the icons locally, and then send a command to the server to trigger it to run said method. Then I would return it's return value back to the client for further processing / display.
What sort of objects / architectures should I be looking at to accomplish such a thing? Would I have a switch on the server to go through various different command possibilities? Couldn't this get out of hand in very large applications? How would I send a "Shortcut" object as a byte stream to the client and then re-create the "Shortcut" on the client?
Implementing remote desktop functionality is not necessary the easiest exercise to learn networking.
To start it may be easier to implement console application redirection or even simple telnet client (you can enable telnet on some versions of Windows to play with without writing server side portion).
If want to learn about how remote desktop could be implemented consider reading about Unix implementation of it X Window System.
As for graphic UI support - read on RDP, or read articles about FogCreek's CoPilot (which implements almost exactly what you want) - CoPilot technical info, or start with list Comparison of remote desktop software to find more info.
Overview
C# File - Users PC
PHP Server - Hosts Webpages for application
Server and Users PC on local network
I have a c# file that reads weight from a USB scale. How would I trigger this file to run so it feeds into my program. The problem is I am using PHP to host our webpage/application so its not running client side and the scale is not hooked up to the server but to the clients PC.
The C# script would have to be on the clients in order to read the scale so how would I trigger this to happen?
Is this even possible and if not what would be a better way?
Important Edit
I was able to run the Scale Script (C#) when I wanted by having PHP and C# use TCP sockets.
The C# would listen for PHP to send something and when it did it would read the scale and send this information back to PHP becuase PHP was listening for a response. Mixed in with a little Ajax and it updates in the web browser.
Gave Chris Credit because he was the most helpful with answering my questions
It sounds like what you really want is for the client application to submit the data to the website itself, and the most suitable approach is probably to expose a web service from your server.
This service should accept weight data, along with some sort of customer key or whatever, to correlate the records correctly on the server side. I've never created a web service in PHP personally, so I can't give any advice on the implementation of that, but it is fairly trivial to hook a C# client app up to a web service once you've exposed its metadata (assuming you use SOAP).
you can't start C# application from a web page in a way that'll work in every browser every time. BUT, you can have some workarounds:
Use ActiveX component that read the data in the client and upload it to the server. the biggest cons is that it'll only work in Internet Explorer
use Silverlight client application that runs on elevated mode (v4) and upload the data to your server.
refer your clients to download application (the C# application you wrote about) and run it - this application will upload the data to your server.
hope this helps.
C# isn't a scripting language, it's a language that compiles into executable binaries or libraries. You won't be able to execute C# code on the client's computer via a website because C# code needs to be compiled before it can run.
Presumably what you really want is for your compiled C# binary to be executed on the client's machine via your website. You won't be able to easily do that. There are a lot of security measures in place to prevent browsers from running programs on your computer. There may be ways to hack around these security measures by using plugins (such as ActiveX), but it's not something that will be a one-liner.
Edit: I think you need to step back and think about what you're trying to do in a broad sense. You're trying to create a website that can read information from a user's USB port. This is the type of thing that browsers are designed to prevent, and for good reason. I wouldn't want random websites to be able to access peripheral hardware without my explicit permission. If you want this website to function the way you're expecting, you're going to have to seriously think about the security implications. You'll need some kind of client-side code (ActiveX, Silverlight, ...), and the user will need to explicitly give permission to for this all to happen. It won't be easy, and it won't be automatic. And I'm damn glad that's true.