It can be REALLY hard to access the desktop using scripts, especially batch scripts, if it has been moved from the default location of C:\Users\%username%, or even worse if it has been moved out of the %userprofile% location by the way of Folder Redirection.
As batch files cannot find this location, and I do not want to start learning VB script, I want a Powershell method I can use to find it.
This is the method I found:
$desktop = [Environment]::GetFolderPath("Desktop")
The $desktop variable now contains the location to the currently logged-in user's desktop. To view this path simply type
write-host $desktop
Happy day!
Reference:
The comment on the post at http://stackoverflow.com/questions/11349885/get-currently-logged-in-users-with-powershell-to-add-shortcut-to-desktop
:-)
As batch files cannot find this location, and I do not want to start learning VB script, I want a Powershell method I can use to find it.
This is the method I found:
$desktop = [Environment]::GetFolderPath("Desktop")
The $desktop variable now contains the location to the currently logged-in user's desktop. To view this path simply type
write-host $desktop
Happy day!
Reference:
The comment on the post at http://stackoverflow.com/questions/11349885/get-currently-logged-in-users-with-powershell-to-add-shortcut-to-desktop
:-)
No comments:
Post a Comment