:: Windows/Linux Sys Admin :: PowerShell Evangelist :: My fascination with scripting started with AWK and has evolved into PowerShell-fanatic.
2009-05-18
welllll, isn't that Special...(Folders)
I was building a Batch script to push out a desktop shortcut to workstations on our domain via SMS. I ran into some issues with the %ALLUSERSPROFILE% environment variable reading from the server environment versus the local workstation environment. Anyhow, I stumbled across the .NET class Environment which provides a static method named GetFolderPath().
List Special Folders...
[environment+specialfolder]::GetNames([environment+specialfolder])
Desktop
Programs
Personal
MyDocuments
Favorites
Startup
Recent
SendTo
StartMenu
MyMusic
DesktopDirectory
MyComputer
Templates
ApplicationData
LocalApplicationData
InternetCache
Cookies
History
CommonApplicationData
System
ProgramFiles
MyPictures
CommonProgramFiles
Retreiving specific Special Folders...
$myDocuments = [Environment]::GetFolderPath("MyDocuments")
Once you've defined the variable you can then reuse it...
get-childitem $myDocuments
Mode LastWriteTime Length Name
---- ------------------ ------ ----
d---- 5/3/2009 7:47 PM folder1
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment