Nameerror in get_special_folder_path

Asked

Viewed 63 times

2

I did a little test in Python 2.X to try copying a file from the folder the script is in to the Windows startup folder:

import shutil
import sys, os

startuplocation = get_special_folder_path("CSIDL_STARTUP")
shutil.copy('fototest.jpg', startuplocation)

however, I get the message:

File "copytest.py", line 5, in startuplocation = get_special_folder_path("CSIDL_STARTUP") Nameerror: name 'get_special_folder_path' is not defined.

I started using Python a little while ago and I don’t understand what’s wrong.

  • 1

    The method get_special_folder_path belongs to which class? Ai is saying that he is not defined.

1 answer

2


Dear friend Pythonista, thank you so much for the language preference hehehe! This script you are making would be for a post-installer?

Otherwise, the get_special_folder_path(csidl_string) function will not work! If you still want to find your computer’s Startup location, use this script (if it’s Windows):

import winshell
startup = winshell.startup()
  • Thank you very much, I didn’t know it only worked in the post-installer. The solution presented solved my problem.

  • Opa if you need help, just call!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.