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")