Get stdout from an idle background application in Windows - windows

I have an ffmpeg.exe process that appears to be hung - it hasn't done anything for several days. It was started by exec() in PHP, so is running in the background and has no window.
I would like to know what caused it to stop/hang.
Is there anyway to get what it has written to stdout?

I don't think I understand you correctly, but I'll try.
If you wanna see its output, you can hook its output functions via IAT/inline hooking and redirect it to a file or something.
However, I think you just wanna see what it is doing. In that case I suggest you to use "Procmon" from the "Sysinternals Suit".

Related

How to clear Windows event logs without showing any error messages?

I'm creating a Windows event log-clearing software.
Whenever you clear logs from the command-line, there are always a few logs that can't be cleared, because either newer versions of Windows don't use the services those logs were meant for anymore, or they are important system logs that are almost always being written to.
However, when the Windows event utility tool finds out it can't clear those logs, it relays an error message to the user. And because I'm trying to make this Batch file into an actual software, I would rather not have a bunch of messy error messages on the screen, for the sake of the user experience.
The obvious answer to this problem would be to have the batch file start a separate background batch script to clear the logs, where the user wouldn't see any error messages, but modern-day anti-virus really don't like batch scripts, and flag them almost every time, so I can't do that.
I tried to instead create a powershell script (Much more trusted by anti-virus.) to clear the logs. But because of the nature of powershell, even if it runs completely in the background, without a console, it still relays error messages in the form of VBS XMessages.
If it's any useful, here's the two lines of code in the powershell script:
wevtutil el | Foreach-Object {wevtutil cl "$_"}
exit
And for those who are wondering, yes, I am clearing logs with administrative privileges.
I need one of the following:
Another way to clear Windows event logs, that doesn't show error messages, that I can integrate into the software I'm creating.
A way to forcefully clear those Windows event logs that normally can't be cleared.
A way to have a batch script run without anti-virus having a stroke.
A way to make the powershell script run completely in the background, without event displaying error messages.
To any who happened to stumble upon this question, the answer is in the comments section, as credit goes to #vonPryz, who mentioned that Clear–EventLog would work better than wevtutil, and it does.

How could a command line tool print to console without stdout or stderr?

I've got a Windows CLI EXE that prints to the console when I run it.
This is not a program I can modify.
I wrapped this in a gradle Exec task, and it clearly is running, but nothing is getting printed to the screen. I had not configured anything special with the output.
I ran the program directly again but used 1> and 2> to redirect stdout and stderr to files.
Because this program takes 3 hours to run I hit Ctrl-C after a while and opened the redirect files.
None of the usual output was in the files.
Could it be using backspace or some other mechanism to prevent output from capture? The output does not clear on the actual console. Any ideas would be helpful.
I found another program by the same author that does not take as long, so I was able to let it finish.
The program does in fact write to stdout, but it doesn't flush until the very end. Which would be 3 hours for the program in the question! I would have thought that flushing would impact the console as well as a redirect stream, but it appears to only impact redirects. This makes sense if you wanted to have an animated progress spinner or something like that. Since I can't update the program code.
It looks like I'm just stuck with no progress updates.

Livecode standalone program takes 30 seconds to load

I've run into an issue with a program I created using Livecode, and now I'm looking for some help from the experts. My Google-fu is strong, yet the answer eludes me...
So here's the deal. I made a very basic note-taking program for Windows only, using very noob skills. I've been using it daily for work for the past month at least. It functions exactly as it should, except for these few things that don't make sense:
When loading the program, it takes 25-30 seconds to load. Not convenient considering it's pretty basic; one button and 5-6 text input fields, with the same number of label fields. And one background. The button just clears the text input fields.
I started to notice a problem when I went to create a batch file to load all my work programs. When the program is loaded thru Command Prompt, if I close CMD it will close the program too. I tried the same using Powershell, and it still closes as soon as the Powershell window closes. Really really strange.
I managed to find another standalone program made with Livecode, downloaded it and tested the CMD command to see if the same thing happened. It didn't, that program loaded instantly and it is ENORMOUS. It also didn't close when I closed the CMD window. I even tried this: opened my program and the downloaded program using the same CMD session, and when I closed CMD, my program closed but the downloaded one did not.
Then, I downloaded the source code for the program that was working correctly. I created a standalone for it, and tried to open that. It acts the same way as my note program does.
I don't get it. It's got to be something in my Standalone Application Settings considering what happened in the last step I mentioned, and I've been over and over those settings for hours, but I just don't have the knowledge of LC to know what to look for. I've scoured the web looking for answers to this, but it seems to be just me having this issue (story of my life, lol).
I'll be happy to post any codes, scripts, or files needed, please let me know. I just don't know which things to post =P
Any suggestions are very much appreciated!! Thank you. =)
If you call the program from the prompt directly, e.g. using
C:\program files (x86)\your_standalone.exe
the app is treated as a command line app. I have also noticed that a LiveCode app can sometimes close if the invoking command line prompt is closed, while it may sometimes continue to run. Perhaps the handling of the relaunch message has to do with it, since this message basically handles commands from the command line.
If you want the command line process to finish independently from the invoked LiveCode application, you can use the start command:
start "" "C:\program files (x86)\your_standalone.exe"
don't have enough info to be able to tell what your issue is. But that much of a delay is not usual for LiveCode apps so something is definitely wrong. How long does your app take to load if you open the stackfile in the IDE?
Not sure what StackOverflow allows but if you could upload your scripts and if possible stackfile that will give us more to go on
This has nothing to do with Windows, Batchfiles, or CMD.
CMD can workaround your problem, if it's a GUI program. See Start command, and read the help as it explains the starting behaviour of CMD and CMD's Start.
Explorer has different rules. Anything else that starts programs call CreateProcessExW which has it's own rules.

Observing and running a program when another program is ran

Lets say I have One.exe and Two.exe. I would like to have a script that will run Two.exe as soon as One.exe is ran and finished loading.
Now, I was wondering what is the better way to do it:
have a script that will be started along with Windows and just sit
quietly in the background, listening for when One.exe will get
started and loaded.
Somehow attach a script to One.exe, so when it runs, the script runs
Two.exe
some other ideas that I don't have yet.
I haven't done any batch scripts yet, so I wanted get into the right way so I know what to search and read about.
Is my idea possible to get realized at all?
Add a simple delay after one.exe is launched with ping or timeout commands.

get console log on MacOSX from another application

With the application Utilities/Console.app, I can see the console output of applications.
Is there a way to access this log from another application?
To be more specific: I am writing a crashhandler for my application and I want that it attaches the console output to the crash information.
Ah, just found out that there is the file /var/log/system.log which contains those information.
/var/log/system.log was not really a solution because the output didn't immediatly appeared there (which was a big problem because how should my crash handler know that everything is complete there), also the grepping of the related messages was very hackish and then, when I started several instances of the application, I didn't really know about the correct related output (unless I knew the pid but even then, also the pid is not unique).
Know, a solution I am very happy with, is that the application itself is keeping track about all the console output. It is doing that by forking itself and piping its output to the fork and emulating the tee tool there, where one output is a special log file. When it crashes, it sends the filename of the logfile to the crashhandler.
If you are interested, look at the OpenLieroX source code ( http://sourceforge.net/projects/openlierox ).

Resources