In which cases does program exit with 0x40010004 code?

On the theoretical side it could be anything, since TerminateProcess has an exit code parameter. On the practical side, it’s most likely due to system shutdown. When Windows shuts down, it tries to exit running programs gracefully (more on that here). If they refuse to quit, they might be terminated by the system with the exit code 0x40010004. For … Read more

Using sys/socket.h functions on windows

You have two options: Use Cygwin (Unix emulation library). Port to Winsock (Windows standard library). Cygwin: lets you compile your Unix sources mostly untouched, but ties you to the Cygwin emulation library. This have two implications: general performance -no only network- will probably be less than optimal; and the target environment must have (at run … Read more

How do I force Robocopy to overwrite files?

In general, Robocopy ignores files for which lastwrittendate and filesize are the same. How can we escape this design? I’d like to force overwriting with Robocopy. I expected that dst\sample.txt should be written test001. But these file are recognized as the same files by Robocopy and not overwritten. The “/IS” option is not effective in … Read more

How to solve “The specified service has been marked for deletion” error

There may be several causes which lead to the service being stuck in “marked for deletion”. SysInternals’ Process Explorer is opened. Closing it should lead to automatic removal of the service. Task Manager is opened. Microsoft Management Console (MMC) is opened. To ensure all instances are closed, run taskkill /F /IM mmc.exe. Services console is … Read more

Difference between $? and $LastExitCode in PowerShell

$LastExitCode is the return code of native applications. $? just returns True or False depending on whether the last command (cmdlet or native) exited without error or not. For cmdlets failure usually means an exception, for native applications it’s a non-zero exit code: Cancelling a cmdlet with Ctrl+C will also count as failure; for native applications it depends on what exit code they set.