Have activex serve and store executable to a known location - c#

I have a web application that runs internally. I need to run an executable (command line application written in C#) from the browser by passing it 2 parameters.
Infrastructure:
Windows XP - 8
Internet Explorer 6+
C# (.Net 4.0)
The code the launches the executable:
var scanApp = new ActiveXObject("WScript.shell");
scanApp.run("C:\\Path\\To\\exe param1 param2", 1, true);
The above works on my local machine because I have the exe in a known location (on my desktop).
My question is, how best can I deploy this on a client machine through activex and then run the executable?
The workflow would be:
1. Go to webpage
2. Click link that attempts to launch exe
3. Activex 'installs/downloads' the exe to a known location if its not there already
4. Run the exe
TLDR
How to deploy an executable through ActiveX and then launch it whenever user clicks on a webpage button?

Is it necessary that the installation occur through ActiveX? If not and you can deploy a different way (Group Policy, ClickOnce, etc), you can register a protocol handler to accomplish your second goal (similar to how iTunes is registered as a handler for itunes:// links). Just make that part of the install script.
For more information on that topic, see here or here.

Related

How to launch 3rd party external application from my own WPF application?

I have wpf application. I need to be able to launch 3rd party external application from my wpf app.
I have searched and found I can use Process.Start() but for that i need the path to 3rd party external applications executable.
Would I be able to get the path for 3rd party external applications executable from my wpf application code?
OR
Is there any process to launch existing apps in windows from wpf application ?
Ex: I need to launch Nvidia GeForce Experience from my wpf application on button click
To know the path of external apps - I can think of 3 ways:
Look at the known Registry Keys for your external apps (like Nvidia
wil lalways make a specific entry and also puts the Install Path and
at times the path to exe)
Assume the user would install at the default location: C:\Program Files - so search in it for the executable
Ask user to do a one time setup by browsing the executable. That way your wpf app can launch it any other time.

Copying Windows Service to Server

At the moment I have a Windows Service and App (Desktop Tray Win Form App with Stop/Start buttons to stop the service and a PING to check the 3rd party API it uses it working and obtain the current balance - It's a Betfair Betting app)
At the moment I am running this off my Win 7 64 bit Desktop but we are moving to a dedicated server Win 2012.
Both the Win Service/Form are in the same project and they reference a DLL which I made that has all the code inside (connects to the DB, 3rd party Betfair API, gets runner/winner info, renews session info etc).
The Windows Server does NOT have Visual Studio on it.
Can I just copy my DLL up to the server, put it in Windows/System32 and Regsvr register it and then copy the .EXE for my Form and Service up to the server?
Also without having the VS Toolset to register a Win Service on a machine what commands do I need to run to install the Windows Service on the Server.
These are 2 distinct solutions, one with the DLL code, one with the Service Project and Win Form Project.
I just want to know the best/quickest/easiest/proper way of getting it to work on the new server without having VS on it to register the service.
Can I just copy the code up to a folder (should it go in a specific folder on the server - the log files are piped out into it's own sub folder of /programdata) and run installutil [PATH TO EXE] to install the Service or is there something more I need to do.
As there are two solutions I can't (or don't know how to) create a deployment package with all the right links and references in across solutions.
However should it be more complicated than..
-Copy DLL to System32
-Regsvr my DLL
-Build the service/win form project on my computer then copy the .EXEs up somewhere
-Run installutil [PATH TO EXE] to register the service
-Double click the windows form to open it (should auto start on reboot and sit in desktop tray)
All in .NET 4.5, Was built in vs 2012, 64 bit, C#
Thanks for any help in advance
Creating a deployment package is the better option, but, because it's not a option for you, the regsvr32 and installutil option should do the job.
Hope it helps!

How do you use CefSharp in a WCF Service?

I am trying to use the CefSharp.OffScreen(41.0.0) Nuget Package within a WCF Service Application, and I'm getting the following error while trying to run the service from Visual Studio 2013:
Could not load file or assembly 'CefSharp.BrowserSubprocess.Core.DLL'
or one of its dependencies. The specified module could not be found.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.
Exception Details: System.IO.FileNotFoundException: Could not load
file or assembly 'CefSharp.BrowserSubprocess.Core.DLL' or one of its
dependencies. The specified module could not be found.
The mentioned assembly is present in the project's bin folder as well as all the required assemblies listed on CefSharp's Website. If there is in fact another assembly required I haven't figured out what it is.
A few other points worth mentioning:
It is easy to reproduce: Start with VS2013's "WCF Service Application" template simply added the CefSharp.Offscreen Nuget Package.
I build the project in x86.
CefSharp also depends on the Visual Studio C++ 2012 redistributables.
I copied those file into the bin folder but still get the same error.
I tried the solutions in the SO question here, to no avail.
CefSharp works fine when referenced from a Console Application or WPF
Application.
Few points,
IIS cannot access Desktop
So you can't run anything that needs a desktop. Your Console and WPF application has access to Desktop and are called user interactive processes.
CEF needs desktop
Cef will need Window manager to create window, without which it cannot render page. This is the reason, the error is misleading here, as IIS cannot load dependent assemblies which require Desktop interaction unless Allow service to interact with Desktop is selected for IIS process in Windows Services.
Console application is only option with Login
You will have to run your application as console and you will need to login to desktop, allowing IIS to interact with desktop is not a good option and I don't even know what kind of problems it might have.
You can set your server to auto login to some user by modifying registry and set your console application in your startup. So this way everytime server will be restarted, your server will automatically login to specified user and your console app will start. (Windows 8.1 has little difficulty but you will get some solution).
Custom Windows Service with Desktop Access
You can change your application type to Windows Service instead of Console and you can install your windows service that allows access to desktop shown in this article, beware, there are problems that this will work only if somebody is logged on to server.
http://www.codeproject.com/Articles/4891/Interact-With-Desktop-when-Installing-Windows-Serv
PhantomJS headless browser
There is PhantomJS headless browser which you can run in IIS/Windows Service without need to interact with desktop, however you will need to shift your code to JavaScript instead of C#. There are other libraries to manage PhantomJS from your app as well.
According to this link it appears that the solution to this problem is to run the CefSharp code in a [STAThread] thread.

Cannot launch File Explorer in Windows Mobile

I've got a .NET compact framework application that I'm porting from Windows CE to Windows Mobile 6.1. The application offers the ability to launch the File Explorer opened to a particular folder as a time-saver for the user when they need to interact with the file system.
The code to do this is trivial (note that profileLocation has the path to the target folder to view):
try
{
string fileExplorer = "\\windows\\fexplore.exe";
Process.Start(fileExplorer, "/root," + profileLocation);
}
catch
{
MessageBox.Show("Could not open " + profileLocation);
}
FYI, this is similar to the code found here on SO (.net cf - launch explorer programmaticly).
This works wonderfully on the Windows CE device (and a version of this code works on the full desktop version of the app too), but on the Windows Mobile version the code does nothing. It does not throw the exception (so I know the process is started at least), but neither does it seem to start the File Explorer.
My first thought was that it was started, but is just behind my application in the stack. But I have confirmed via CE Remote Spy and CE Remote Process Viewer that the process is not present at all.
Has anyone achieved this before on a Windows Mobile device?
EDIT:
Based upon the suggestion below, I have confirmed that the following code does work:
Process.Start(fileExplorer, null);
Now I just need to determine what command line options can be used to get File Explorer to launch with the desired file location selected. Anyone know what command-line options are available for FEXPLORE on WinMo?
Possibly fexplore.exe is blacklisted. Can you start fexplore manually?
Try without using a argument and just launch fexplore.exe.
Try your code with another exe.
Generally the code should work fine on windows mobile 6.1.

Run a ClickOnce application from a webpage without user action

We have a Java based web-application and also the same application written in C# which should be run if the java-checker finds out that there's no Java installed on the client machine. The idea is to run the C# ClickOnce application automatically, without any user action, once the Java checker reports that there's no Java installed on the machine. Is that possible and if yes - how?
Just link to (or redirect the browser to) the URL of the ClickOnce application. That should launch the application.
For example, http://www.domain.com/myapp.application

Categories

Resources