Windows Python: how to get opened file path from within the associated file type handler program?

102 Views Asked by At

I am using Windows. I have files that are AES encrypted and saved with a certain file extension. What I want to do is to write a python program that I can use as the handler for that file type. In other words, when I double-click a file of that type, it should start my python program, which will then process the file. So far I have it to the point where my program runs in response to such a file being opened.

What I am stuck on is this: When I open a file that triggers my handler to run, how do I find the location of that file from within the handler program?

For example:

  • .abc is associated to C:\Program Files\my_file_handler.py, so my_file_handler.py will run whenever I double-click a .abc file
  • I double-click C:\Users\my_stuff\cool_aes.abc
  • C:\Program Files\my_file_handler.py runs

within my_file_handler.py, how do i determine that C:\Users\my_stuff\cool_aes.abc was the file that triggered it to start? Is that information available in sys or os packages, or somewhere else?

0

There are 0 best solutions below