AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |
Back to Blog
Get current explorer exe process id c11/12/2023 ![]() ![]() With enough iterations and a bit of luck, I suppose a collision could eventually occur, thus giving a false result. A command session could be started that intentionally mimics the encoded UID within the command line. The only way I can see my script failing is if someone intentionally attempted to break it. I have used exclusive file locks on many batch projects to serialize events, and exhaustive testing has never uncovered a problem. Again, this is a moot point, since the technique has already failed. But I believe it may be possible for two processes to have identical CreationDate values. I haven't seen anything on the web one way or the other as to whether two processes can be launched at precisely the same time (within precision of the system clock). Again, supposing the first WMIC call did return the correct CreationDate, I'm not sure the value is guaranteed to be unique.You could immediately return the ProcessID without requiring a second WMIC call. If you could somehow guarantee that the first WMIC command returns the correct session, then there would be no need to get the CreationDate. ![]() I introduced a pause at the top of the script, and launched two processes via double clicking the script from Windows Explorer. It is impossible to know if the correct one was selected. The last one listed will be the value that is saved. The first WMIC command will return all processes that have the batch script path in the command line.
0 Comments
Read More
Leave a Reply. |