PowerShell Desktop Variable

You can use the Environment.GetFolderPath() method to get the full path to special folders: $DesktopPath = [System.Environment]::GetFolderPath([System.Environment+SpecialFolder]::Desktop) This can be shortened to: $DesktopPath = [Environment]::GetFolderPath(“Desktop”) You can also get the “AllUsers” shared desktop folder (if the shortcut file is shared among all users): [Environment]::GetFolderPath(“CommonDesktopDirectory”) Check out the full list of values for the SpecialFolder Enum.

How to get Desktop location?

On Unix or Linux: import os desktop = os.path.join(os.path.join(os.path.expanduser(‘~’)), ‘Desktop’) on Windows: import os desktop = os.path.join(os.path.join(os.environ[‘USERPROFILE’]), ‘Desktop’) and to add in your command: shutil.copy(txtName, desktop)

What’s the difference between SpecialFolder.Desktop and SpecialFolder.DesktopDirectory?

Answer to original question A directory is a location in the file system. A folder is a location in the shell namespace. A directory is a kind of folder. A virtual folder is not necessarily backed by a directory. For example consider libraries or search folders. The user’s desktop directory is a location in the … Read more

What’s the environment variable for the path to the desktop?

To be safe, you should use the proper APIs in Powershell (or VBScript) Using PowerShell: [Environment]::GetFolderPath(“Desktop”) Copy something using Powershell: Copy-Item $home\*.txt ([Environment]::GetFolderPath(“Desktop”)) Here is a VBScript-example to get the desktop path: dim WSHShell, desktop, pathstring, objFSO set objFSO=CreateObject(“Scripting.FileSystemObject”) Set WSHshell = CreateObject(“WScript.Shell”) desktop = WSHShell.SpecialFolders(“Desktop”) pathstring = objFSO.GetAbsolutePathName(desktop) WScript.Echo pathstring

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)