Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8373111
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T14:35:52+00:00 2026-06-09T14:35:52+00:00

I am trying to create a python program to easily change my cmd startup

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T14:35:54+00:00Added an answer on June 9, 2026 at 2:35 pm

    You have to use SetValueEx and also open the key with appropriate access rights, either KEY_WRITE or KEY_ALL_ACCESS, like this:

    from winreg import*
    
    a=OpenKey(HKEY_CURRENT_USER,"Software\\Microsoft\\Command Processor",0,KEY_WRITE)
    SetValueEx(a,"Autorun",0,REG_SZ,"cd\\The path that I wantsss.")
    CloseKey(a)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to create an exe file from my program written in Python
I'm trying to create a python program (using pyUNO ) to make some changes
I have been trying to create a simple program with Python which uses OpenCV
I'm trying to create a Python script that would : Look into the folder
I'm trying to create a word ladder program in python. I'd like to generate
I'm using python 3.2.2 on windows 7 and I'm trying to create a program
i m trying to create windows executable from python program which has GUI .
I am new to python and I'm trying to create a program that creates
I'm new to Python OOP and trying to create a OOP program to manage
Python newbie here, running 2.7. I am trying to create a program that uses

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.