I am trying to create a python program to easily change my cmd startup folder(rather than typing cd … to navigate to the desired file)
But first I need to figure out how to change it without having to type regedit.exe into cmd.
After going through python documentation this is where I got:
from winreg import*
a=OpenKey(HKEY_CURRENT_USER,"Software\Microsoft\Command Processor\\")
SetValue(HKEY_CURRENT_USER,"Software\Microsoft\Command Processor\\",REG_SZ,"cd\\the path that I want.")
This code does edit the string value (I believe that is what its called) Default.
But what I need it to do is to edit the string value Autorun
#I tried diffrent ways of putting Autorun in that SetValue function but it didn’t work.
Note: both Default and Autorun are in HKEY_CURRENT_USER\Software\Microsoft\Command Processor.
I’ve also tried
SetValueEx(a,"Autorun",0,REG_SZ,"cd\\The path that I wantsss.")#Don't know if this is the right way to use it.
But this gives me this error:
Traceback (most recent call last):
File "<pyshell#10>", line 1, in <module>
SetValueEx(a,"Autorun",0,REG_SZ,"cd\\The path that I wantsss.")
WindowsError: [Error 5] Access is denied
I use python 3.1 and windows7
Thank you in advance.
You have to use SetValueEx and also open the key with appropriate access rights, either KEY_WRITE or KEY_ALL_ACCESS, like this: