User Folder Variable
I'm trying to find out if there is a user folder variable for scripting.
Example: C:\Users\UserName
I found the below list, but I'm not seeing any reference to a user folder.
https://www.itninja.com/blog/view/kace-quick-reference-to-scripts-variables
Answers (2)
Well, if you use Scripting, the default user which is used is SYSTEM. And SYSTEM does not have a user folder.
So you have to use the Windows-Variable which only works if you run the script as "logged in user" or as a determined user and then it links to their local user folders
Comments:
-
Let me give it a try as "logged in user". I never though to do that! - mcclainr@tessco.com 3 years ago
What is your end goal?
The environmental variable for a users directory in windows is %userprofile% or $env:userprofile in powershell, but as Nico stated this wont have the desired effect if you're running the script as "system".
You can configure scripts to run as a "logged in user" but there are some nuances to doing that.
Depending what you're trying to do I probably have a code snippet or two I could share.
Comments:
-
The end goal is to uninstall the RingCentral application that does not get installing in the usual "program flies" folder. It's installed within the users AppData folder. I will try running it as "logged in user" as suggested by Nico_K. - mcclainr@tessco.com 3 years ago