windows automated task - c#

i have c# program to save the path of the files and the password.
How can my program talk with backend program (ie 3rd application program) transparent to the user, to perform the tasks. And based on the data i captured using my c# progeam, given to use with that 3rd app program.
My C# program is just a frontend interface to automated the repeative task for keep manual operation from one source folder to destination folder to save operator time.
The problem is, i don't understand how to do this. I only know we need something like window automate task to get that done. How can i integrate my program + 3rd app.+window automate task, together?
thank you very much.

Create your program as a Windows Service, and make it run constantly
As for the data passing goes, you can output an XML file ( or write to a database), and let the 3 party app to use.
You may want to write a clearer question next time.

Related

Multiple executable accessing the same folder at the same time

We have a python application that checks a directory(C:\sample\folder) every 5 seconds, there's also this external application(.net app) that puts file into that same directory (C:\sample\folder).
Will there be any conflict when the two application access the same folder at the same time (accidentally)?
Conflicts like :
the external app wont be able to place a file because the python app is currently walking through that same directory?
It should be fine for the external app to create and write to a file. If the Python app is reading a file, the .NET app may not be able to write to it while Python is reading it, without both processes opening the file in a shareable way, however.
Likewise if the Python app is going to start reading the newly-created file, it may either find that it can't do so until the .NET app has finished writing to it, or it may read incomplete data. Again, changes would quite possibly be required to both processes to allow reading at all.
It's worth thoroughly testing all the poosibilities you're concerned about, possibly involving the creation of a "fake" external app which writes to a file very slowly, but opening it in the same way that the real one does.

How to Run a Program and Get its Output

In C#, I want to run a program and wait for the user to exit in order to get what was saved. For example, I want to run Photoshop or MSpaint, wait for the user to finish editing and, after saving, to get the file (jpg, png, etc) or at least the path of the file.
I have been unable to determine how to go about this.
It's probably going to depend heavily on the program you wish to use. If you use a program with an API to make calls and get feedback, then maybe you can do this. For Photoshop and MSPaint, I'm a bit skeptical they'd have this feature. In the end, what you might wish to do, is keep some kind of input box open and await the user to paste the path themselves. Either that or find such a program with the API you're looking for or make your very own image editor.

How to call an external windows application with UI by a c# application?

We have a program (A.exe) with GUI and a toolbar who does NLP stuff with some text.
In that toolbar we have function A which transform the text by adding some xml tags. Someone here (the boss) would like that I create a Web Service calling function A. It told me about Dynamic Data Exchange (he used it few years ago), I saw something like SendMessage.
The Web Service will be used by someone over the Internet : sending a text and getting the result as xml. The GUI program could not be started when someone calls the WS because it is too slow, so someone sugggests to launch this A.exe once for all and the WS will ask this A.exe by sending a DDE call. I don't know how A.exe will react in case of concurrent calls.
The Web Service will:
save the text file in a directory
call the A.exe
the A.exe will compute the text file and create the xml file
the WS will loop until the xml file exist
the WS will get the xml and send it as stream to the original caller
I would like to note that:
DDE is old and seems to need a DDE server capable program.
SendMessage is a little bit obscur as I am a Java developer.
I did not try named or anonymous pipes to make that call as suggested.
Thank you.
PS: It is an heresy to build a WS calling a server-side program with UI, isn't?
The answer to this question really depends on what you are trying to accomplish. Does your function alter data coming from an external data source such as a database or are you invoking a function within an application?
I would start with the following questions.
1) What does the function of the button do? Can it's functionality be moved into a service and shared between multiple applications?
2) Can you put the functionality inside a DLL and share between two applications?
3) Do the two apps really need to communicate with one another?
If the two processes MUST communicate with one another and you merely want application A to behave in response to a message from application B, consider using named pipes for TCP/IP communication. This is simple enough in .NET and provides quick communication between processes.
UPDATE: Here is a link with info on using named pipes: http://msdn.microsoft.com/en-us/library/bb546085.aspx.
UPDATE 2: This is an update after you updated your question. Do you have access to A.exe's source code? If you do, you have two options: 1) move that logic into your service or 2) modify A.exe to accept command-line parameters so that your service can invoke the process and get back results. If you don't have source code and you can't invoke A.exe from the command-line, then there isn't much you can do other than write the process yourself in a form your web service can call.
P.S. You don't have to worry about concurrent calls because each server request will execute a separate process.

Running Java Application in C# NET

I wrote an application a while ago in C# NET that basically allows the .exe I created to start/stop when the java application (Minecraft) starts and stops.
I would like to extend some more functionality to my application by basically allowing users to type commands into my console app, and in turn send these commands to the .jar file that is running.
I read something a while ago on stackoverflow that said there were some APIs that would basically let you manage Java apps inside of a C# NET app but I can't find it now.
Does anyone know how I could go about doing this?
If you launch and manage the java app from C# using the Process class, you can send input from your C# app to the launched java app process via Process.StandardInput.
Minecraft accepts commands from system in and responds to system out.
When you start minecraft from your application you basicly creates a new process. This process has two streams, one for system out and one for system in. You need to get hold of those streams. If you send characters to the system in stream, then they will be interpreted as commands to minecraft. If you read from the system out stream then you will get minecrafts response.
Your next task would be to let your users send commands to minecraft. One way to do this would be to let your users type in commands on a web page that you store in a file. You could have a separate thread read from the file and write the commands to minecraft's system in stream.

Ensuring Windows Mobile application is not running - From a desktop app

I have a windows mobile 5.0 application (smartphone) that contains a flat data file (CSV), which contains a header row (two doubles), and a list of entries (two doubles, DateTime, and a string).
Occasionally, I need to "sync" the mobile application with a desktop application. The desktop application should read the CSV from the mobile device, and replace it with a new CSV file, based on the contents of the old one.
This seems pretty easy via RAPI (I'm guessing), but I need to ensure that the mobile application is not running. Is there a way to do this?
Mutex? Remote Process Viewer like stuff? File locking?
Thanks for any help you have
Mike
Just use a simple file locking mechanism for the file being read/updated.
Either rename the file before use or create a second 'lock' file which you can check for the existence of.
For whatever reason, the built-in RAPI Functions don't have anything for checking running processes like the ToolHelp API's. With C you could create a set of custom functions in a device library that call the ToolHelp APIs and in turn are called through CeRapiInvoke (which is a generic catch-all entry point for custom RAPI functions). Unfortunately there's no simple mechanism to do this in managed code.
Just thought of an easy way.
Every 3 seconds the program is running, update a registry key with the current datetime.
When I want to sync, check the mobile registry, check it again 5 seconds later. If the values changed, the program is still running.

Categories