Hack Forums
[Python] Questions| is there a way i can make my python script add itself to the registry? - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [Python] Questions| is there a way i can make my python script add itself to the registry? (/showthread.php?tid=5193505)



Questions| is there a way i can make my python script add itself to the registry? - JBlock - Mar 5, 2016

is there a way to make my python script add itself to the registry
when i execute the script for the first time?


* - RiperFish - Mar 6, 2016

maybe this is what you are looking for :
https://docs.python.org/2/library/_winreg.html


* - Goodies - Mar 6, 2016

There's the hard way (do not recommend):
PHP Code

<?php 
import os
cmd 
= 'reg add "HKCU\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run" /V "StartupPythonScript" /t REG_SZ /F /D "C:\\Windows\\System32\\cmd.exe /k \'python {}\'"'.format(os.path.abspath(__file__))
system(cmd) 

I think that'll work. May need some tinkering. Also, must be run as admin. You can also use _winreg (renamed to winreg without underscore in Pythhon3). I can't be bothered to google it, but RiperFish posted a link to everything you need.

Important command:
cmd.exe /k "python script.py"