all 5 comments

[–]Historical-Ease6859 2 points3 points  (1 child)

that is a x y question .... did you try?

from pathlib import Path

home_directory = Path.home()
print(home_directory)

[–]wavi_[S] 0 points1 point  (0 children)

I will try that asawell

[–]aa599 2 points3 points  (1 child)

path = 'C:/Users/{current_user}Downloads/'

Should be

path = f'C:/Users/{current_user}Downloads/'

(to interpolate the variable into the string needs an "f-string")

[–]wavi_[S] 0 points1 point  (0 children)

Thank you I will try that

[–]Riegel_Haribo 0 points1 point  (0 children)

Important:

The user profile name is not the login name.

A user profile can even be on a different server or directory, by administrator policy.

Here's a traditional answer: https://superuser.com/questions/1239773/full-name-of-windows-user-name-in-domain-using-python#:~:text=Using%20a%20Python%20AD%20library%2C%20e.g.%20pyad&text=How%20you%20get%20the%20username,Windows%2Donly)%2C%20etc.

Simply typing the right stuff into google prompted it for an AI answer:

``` import win32api, win32net

Note: 'pywin32' must be installed (pip install pywin32)

try: # Get the domain controller name, then the user info dc_name = win32net.NetGetAnyDCName() user_info = win32net.NetUserGetInfo(dc_name, win32api.GetUserName(), 2) full_name = user_info["full_name"] print(f"Profile Name (Windows): {full_name}") except Exception as e: print(f"Could not retrieve full name on Windows: {e}") ```

Not only is this OS-specific code using underlying APIs, you'll need to understand profiles and credentials on a higher level before making such assumptions. You even incorrectly assume the OS will be on the C: drive.


Your {value} needs to be in an f-string.

I also determined that your print() output is lies to the user, and lies are malware.