0

I need to get the location of the startup folder, like so: on my computer it looks like this:

C:\\Users\\pc\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Startup 

but how do I get the path to this folder on any computer using Python?

I'm trying to use the function shutil.copy2() replacing the A below with the path to startup

shutil.copy2("C:\\Users\\NAME_OF_USER\\Downloads\\file.exe", "A")
0

1 Answer 1

1

You can expand the USERPROFILE environment variable in Windows to get the path to the current user's directory

import os

a = os.path.normpath(os.path.expandvars('$USERPROFILE') + 'AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup')
shutil.copy2("C:\\Users\\NAME_OF_USER\\Downloads\\file.exe", a)
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.