A package that checks if a directory is present in the user's profile
Published: February 16, 2021 - 09:41
Hello,
We need to check if a directory is present on the desktops of machines used with a generic Active Directory account.
The directory must be located on the desktop of that account.
We would like to deploy a package to the affected machines that returns some result in their audit (for example, whether the directory is present or not).
We have written the code in the `def audit` section of the package for this purpose.
We are trying to retrieve the name of the user currently logged into the machine to build the search path (c:\users\'username'\desktop\...).
However, we have tried several methods, but they either return the machine name or incorrect information:
`os.environ['USERPROFILE']` returns `C:\WINDOWS\system32\config\systemprofile`, `
win32api.GetUserName()` returns `SystÞme`,
`os.getenv('username')` returns the machine name (e.g., `my-machine$`),
`getpass.getuser()` returns the machine name (e.g., `my-machine$`).
Do you know why? We've been stuck for a while.
Thank you.
We need to check if a directory is present on the desktops of machines used with a generic Active Directory account.
The directory must be located on the desktop of that account.
We would like to deploy a package to the affected machines that returns some result in their audit (for example, whether the directory is present or not).
We have written the code in the `def audit` section of the package for this purpose.
We are trying to retrieve the name of the user currently logged into the machine to build the search path (c:\users\'username'\desktop\...).
However, we have tried several methods, but they either return the machine name or incorrect information:
`os.environ['USERPROFILE']` returns `C:\WINDOWS\system32\config\systemprofile`, `
win32api.GetUserName()` returns `SystÞme`,
`os.getenv('username')` returns the machine name (e.g., `my-machine$`),
`getpass.getuser()` returns the machine name (e.g., `my-machine$`).
Do you know why? We've been stuck for a while.
Thank you.