0

I want to get path to roaming, which should end up like this in my case: A:\Users\Mitja\AppData\Roaming

But when program is ran as windows service all I get is: C:\Windows\System32\config\systemprofile\AppData\Roaming

I tried multiple libraries, but all did the same. Does anyone maybe know how would I get the path?

I already tried all of these:

roaming_folder = os.getenv('APPDATA')


roaming_folder = os.path.expanduser('~\\AppData\\Roaming')

roaming_folder = os.environ['APPDATA']

def get_appdata():
    CSIDL_APPDATA = 26
    SHGFP_TYPE_CURRENT = 0
    buf = ctypes.create_unicode_buffer(ctypes.wintypes.MAX_PATH)
    ctypes.windll.shell32.SHGetFolderPathW(None, CSIDL_APPDATA, None, SHGFP_TYPE_CURRENT, buf)
    return buf.value
roaming_folder = get_appdata()


import win32com.client

shell = win32com.client.Dispatch("WScript.Shell")
roaming_folder = shell.SpecialFolders("AppData")
virtualdvid
  • 2,323
  • 3
  • 14
  • 32
Knedl
  • 1
  • 1
  • My solution [https://stackoverflow.com/questions/16922107/get-user-appdata-path-from-windows-service-by-running-service-under-local-profil][1] – Knedl Feb 11 '23 at 16:31

0 Answers0