Execute Program Without Clicking - c#

Is there a way for a program to be executed without clicking on it? Is it possible for it to be executed the minute you receive the file?
I want to build a c# application that executes any file sent to the machine from another machine connected to it. I want to do this without remote desktop, so I would check a checkbox that says "execute when finished sending" and when it is received, it would execute the program. So I would essentially be able to remote desktop, without actually remote desktoping.
Thanks in advance

Do you realize what you are proposing? If this was possible, every machine out there would be infested with the nastiest viruses.
Why don't you build a server part that you leave running on your remote machine and then have it execute whatever your heart pleases.

There is a program out there (currently in Beta) called SkyNet that does this. You can drag and drop a URL or file onto one of your "Contacts" and (for a URL) it will open an new tab and navigate to that site on your friend's computer. For files, it automatically drops them on that person's desktop.
So it is definitely possible.

Perhaps you want to use secure shell. There are clients and servers for various platforms (you didn't specify) and you can run programs remotely. This is useful for e.g. automated testing.

Related

WPF Window is not Opening from IIS [duplicate]

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?

Windows 2008R2 service that runs another app, after cold reboot

Im working on application for Windows Server 2008 R2 (.NET 3.5.1) that would work even after cold reboot, without requring someone to log on any account on the server.
Few words about application itself, it is written in c# application for registering employees work time at the company. Users (employees), have thier cards which are beeing scanned by barcode scanner, each scan means either "work started" or "work stopped", everything is serlialized into xml file which is later on modified and put into .csv but that doesn't matter.
Barcode scanner is working as a keyboard, so all codes are beeing "typed" like from a keyborad, to the PC. I made application read the keys despite the fact that console application is not in focus, or not visible at all.
What i need to do is to make that application work even after cold reboot, it has to be fully automatic.
So far i figured out 2 approaches to do it, one is to create a service which would keep another process alive (if its not working, just turn it on), i didin't have much luck with this one, i have already created service that launches another process for me, but the process is working differently, if i would run it myself, there is no communication with the process so i cannot even tell if its the right one.
Another one is to just put my app into registery /microsoft/windows/current version/run, and enable autologon for user with limited prividges. This actually could work but it is not perfect solution, because after all we do not want to have user logged in on server in company 24/7 right?
I know that most of you are way more experienced in programming than i am, so i would appriciate any solutions how to solve my problem
Lichoniespi
Your options depend on physical security of the system (whether passers-by can do much to it apart from scanning a barcode), but let us assume that it is an easily accessible desktop. In that case, you probably do not want a logged in user.
Use the service approach. You do NOT need a separate process for accessing the keyboard. Create a global hook of type WH_KEYBOARD_LL.
Declare your callback function like this and put it into place with SetWindowsHookEx.
I would use the first approach, create a service, and to comunicate with the running application i would be using a network socket or pipe. For the service be sure that you're using an existing user account (not System) and allow it to interact with the Desktop.

How can I block access to certain site until reboot, WITHOUT changing hosts file?

Here's what we'd like to achieve via a c# application. Is there a way this can be done, or is it impossible?
Block access to a website (say www.stackoverflow.com) between 11am and 2pm.
Also block access to MSN Messenger between the same hours.
Stop the blocking if the machine is rebooted.
What's confusing us is the exact point where the blocking belongs. The only possible solution we have at the moment is programatically altering the hosts file to block and unblock certain sites. This solution would fall down on a few points.
The user can manually change the hosts file back, which would be undesirable.
If the user had a browser open at 11am they would have to restart it to pick up the amended hosts file.
I'm a web developer so not entirely sure how this works, but I believe the c# app would have to be running as an administrator in order to edit the hosts file, which again would not be desirable.
To clarify, we're trying to produce something like macfreedom.com - so users's aren't going through a proxy or network that we control (unless the solution is to make the user's machine point to a proxy server but I doubt that's achievable or desirable). macfreedom.com appears to work by switching off the network adapter until reboot. We were hoping for a more subtle effect.
this should work like the most client firewalls ... a network filter driver dropping packets ... i fear you will have to use a kernel mode driver -> so .net seems to be out of the game ...

Copy a file on a network path without transfering it to my own machine

If my .NET client uses System.IO.File.Copy to copy a file from \server1\share1\file1.txt to \sever1\share2\file2.txt, the file's data get read down to the client and then written back up to the server.
Is there an easy way to speed up things a bit by putting a process on the network-machine that realy does the copying?
I dont look for advice on programming such a service. I would rather find the tool or windows-functionality that already does this.
This sounds like a job for telnet or ssh, but these can be a pain to set up. I recommend you look at PsExec from microsoft which allows you to execute programs on a remote machine. You could simply use the copy program found in system32 through PsExec.
There is no need to create your own program to do this, just use the command line tools found on the target machine.
Almost certainly. I can think of a couple basic ways to do it:
Create a simple console applicaton that takes the source and destination paths/filenames, and performs a File.Copy(). Place it on the remote machine in a known location. Then invoke the process on the remote machine using PsExec. Your client app must be running in full trust in order to invoke a process programmatically, and the user running the app must have permission to run programs on the remote server.
Create a simple web method that again takes the source and destination and performs the copy. This requires setting up IIS on the network server with the requisite permissions to perform file access outside of the IIS "sandbox". However, it requires fewer client code permissions.
FYI CopyFileEx already does this if your client and server are Vista and later. So, not point in duplicating any of that effort in that case.
-scott

How can I start an application on a different system remotely?

I've got a situation where i have one system running a master application that communicates with slave applets on other systems, problem is, i can't guarentee that the slave applets will be running, nor that an operator can physically utilize the system to start the applet (and I'm also assuming they don't know how to use Remote desktop, these are minimum wage test operators)
Is there an easy way to remotely launch an executeable on another system?
security is not a concern here as this is a closed network.
If you're on the same network and have access credentials (username+password) to the remote computer, then Mark Russinovich's PsExec is just the tool you need.
WMI is your friend. See the following article which covers starting processes locally and remotely using WMI:
How To: (Almost) Everything In WMI via C# Part 2: Processes (CodeProject)
Kev
You can use the Windows AT command to schedule tasks on a remote machine.
Any chance of converting the remote applets into Windows services? They can be configured to start when the system starts; to retry if they fail; and to notify someone if there are problems. They're quite trivial to create with Visual Studio.
here's a 2 step solution
Write a batch file to kick start
the application/service in the
context
Have the batch file on a
shared network path which can be
accessed from the machine would like
to launch the application/service.
Honestly, I would suggest the PsExec solution by Piskvor. But you can try out this as well ;)
another simple solution if you're not on the same network (accessing your home computer to run teamviewer for example) is to create a rule in Outlook (if you have it) whereas if you receive an email say from yourself, you can have it start an application if there are certain pieces of text in the message body or subject line, for example:
Create a mailbox rule:
Step 1 - Conditions: From & With specific words in the body (from being your mail address and the message body: Start Teamviewer
Step 2 - Start Application (browse to the location of the .exe you want to launch)
Step 3 - enable that bad boy!
Obviously, you have to have Outlook open and accepting incoming mail in order for this to work.
you can tailor this to your requirements, ie: if Start Teamviewer is too easy, you can put codes or passwords in there too, so when the email arrives, it'll read the message, recognise the info based on the rule, and launch the application. :)

Categories

Resources