My friend's birthday is coming up, so another friend and I are working on a birthday card/prank. We wrote a short Python script that, upon execution, sleeps for a certain amount of time and then launches the virtual birthday card. We want to send our friend a file (say, the day before his birthday), telling him it's a picture of us or something unsuspicious (the filename would of course end in .jpg or something along those lines) but when he opens it, he actually just activates the sleeper (which will then launch the virtual birthday card the next day, or whatever, depending on when we send it) and surprise him on his actual birthday. (He never turns off his computer, so we're not worried about the whole 'sleep' thing.)

So anyway. The trouble is that if we call it filename.jpg, his computer will automatically open it with an image viewer (i.e., Preview if on a Mac). Is it possible for us to programmatically change the default application that attempts to run our program? That is, is it possible for his computer to run the Python file upon him double-clicking (or otherwise attempting to open) the file?

有帮助吗?

解决方案

As pointed out by Makoto, this is exactly what you do when you send a person a trojan / virus. In general, files downloaded from the internet are not executed without warnings (jpgs are not executable anyway), and even so, a competent computer user will probably get suspicious.

Having said that, if you are the unstoppable kind and he is a close friend and who trusts you with his computer, I suggest that you recruit another friend to divert your birthday friend away from his computer and run the python script in the background.

It will be sure to surprise him and really freak him out, if its done right. It would be a good april fool's joke too.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top