问题
I am developing a key-logger on Python (only for curiosity sake). And the script will be an executable. Without access to the computer so the process should not need a UI or user interaction.
Is there any way, even in another executable to make the key-logger start at start-up ?
回答1:
I don't use Windows, but you can try making a batch
script that runs your python file and make that script Run a program automatically when Windows starts:
Click the Start button Picture of the Start button , click All Programs, right-click the Startup folder, and then click Open.
Open the location that contains the item you want to create a shortcut to.
Right-click the item, and then click Create Shortcut. The new shortcut appears in the same location as the original item.
Drag the shortcut into the Startup folder.
As I said, I don't use Windows, so it might be totally wrong.
You can refer here for making the BAT
file, which basically says:
@echo off
python c:\somescript.py %*
pause
回答2:
Use VBScript:
1-> create anyname.vbs with this data:
Set wvbs=CreateObject("Wscript.Shell") wvbs.run "full location of your File",0
2-> copy anyname.vbs file in C:\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup this folder
Now when windows start it will run your file in hidden mode
回答3:
Open run with "Start + R", then open "shell:startup". it opens you a folder(the folder that was mentioned before at start menu), and every file that is on this folder, well run at startup.
The folder path is: "C:\Users\USERNAME\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup"
(you can copy it on windows explorer, or copy this path and put your account name on USERNAME)
this is the trick i used in my script:
from os import getcwd
from shutil import copy
copy(getcwd()+'/FILE_NAME.exe','C:/Users/USERNAME/AppData/Roaming/Microsoft/Windows/Start Menu/Programs/Startup')
They are some ways for file name as well, but im not familiar with it. this code copies it self to startup folder and starts each time windows boots
来源:https://stackoverflow.com/questions/31130960/run-a-python-program-at-start-up-on-windows