Click here to Skip to main content
15,887,444 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

I have a process (baretail.exe) already running in my PC. On the same process I want to open another text file. Basically I want to change/set the argument of the process. Is it possible to do that? Any comments really appreciate.

Thanks
Posted

Nope. A process reads its arguments at startup.
However, if you can modify it, then you may use some sort of IPC[^] for passing it parameters at runtime.
 
Share this answer
 
You can do that, if you handle that text file was changed. In the changed event of text file, you can restart that process to get new arguments in text file.

Ex:
C#
private void Form1_Load(object sender, EventArgs e)
{
    FileSystemWatcher file = new FileSystemWatcher("C:\\Text.txt");
    file.Changed += new FileSystemEventHandler(file_Changed);
}

void file_Changed(object sender, FileSystemEventArgs e)
{
    //Restart your process here (stop and start)
}

Note: Don't always open this text file when reading arguments to execute process, because this time will lock text file, so you cannot edit text file.
Hope this help
 
Share this answer
 
v2
In case of baretail there is no ipc, and if you start it, you get a new instance. You could however try to automate it, by emulating user action: sending windows messages to the process. You can use AutoIT to capture events and get an overview, or something like WinSPY[^] and Window Detective[^] to see what messages are sent.

But it would be probably easier to make a replacement of that application directly in c# that is capable of doing what you want.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900