SOLVED

Récupérer le chemin du "Bureau"

%3CLINGO-SUB%20id%3D%22lingo-sub-1338493%22%20slang%3D%22fr-FR%22%3ERecover%20the%20path%20of%20the%20%22Office%22%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1338493%22%20slang%3D%22fr-FR%22%3E%3CP%3EGood%20morning%20to%20all%20of%20you.%3C%2FP%3E%3CP%3EI'm%20new%20to%20Powershell%20in%20Windows%2010.%20I%20was%20more%20used%20to%20batches%20under%20DOS%3CIMG%20class%3D%22lia-deferred-image%20lia-image-emoji%22%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Fhtml%2Fimages%2Femoticons%2Ffacepalm_40x40.gif%22%20alt%3D%22%3Afacepalm%3A%22%20title%3D%22%3Afacepalm%3A%22%20%2F%3E%3C%2FP%3E%3CP%3EThe%20path%20of%20personal%20records%20is%20subject%20to%20various%20location%20changes.%20At%20home%20they%20are%20all%20in%20the%20disk%20D%3A%3C%2Fimg%3E%20in%20a%20folder%20in%20the%20name%20of%20the%20user.%3C%2FP%3E%3CP%3ED%3AJC-Mes%20Documents%2C%20D%3A-JC-Mes%20Vid%C3%A9dos%2C%20D%3AJC-Bureau%2C%20D%3AJC-Ma%20Music%2C%20etc.%3C%2FP%3E%3CP%3EFor%20my%20wife%20it's%20D%3A%3C%2Fimg%3E%20Sylvie-My%20Documents%2C%20D%3ASylvie-Bureau%2C%20etc.%3C%2FP%3E%3CP%3EDitto%20for%20my%20children%2C%20etc...%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESo%20I'm%20looking%20to%20retrieve%20in%20a%20variable%20the%20path%20of%20the%20desktop%20depending%20on%20the%20user%20who%20uses%20my%20Powershell%20commands%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EExample%3A%3C%2FP%3E%3CP%3E%3CSTRONG%3E%3CEM%3E%24MonBureau%20'%20D%3AJC'%20Office%3C%2FEM%3E%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%3CEM%3E%3CSTRONG%3Esysteminfo%20Out-File%20%24MonBureau%20Info_Syst%C3%A8me.txt'%3C%2FSTRONG%3E%3C%2FEM%3E%3C%2FP%3E%3CP%3ETo%20retrieve%20system%20info%20in%20a%20text%20file%20from%20JC's%20office%20%24MonBureau%20.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20don't%20know%20where%20or%20how%20to%20retrieve%20this%20desktop%20path%20specific%20to%20each%20user%20in%20my%20variable.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you%3C%2FP%3E%3CP%3EIt's%20not%20going%20to%20be%20a%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIn%20batch%20DOS%2C%20I%20get%20back%20the%20way%20in%20the%20registry%20with%3A%3C%2FP%3E%3CP%3E%3CEM%3Efor%20%2Ff%20%22usebackq%20tokens-1.2%2C%22%20%25%25B%20IN%20('reg%20query%20'HKEY_CURRENT_USER-Software-Microsoft-Windows-Windows-CurrentVersion-Explorer-User%20Shell%20Folders%22%20%2Fv%20Desktop')%20do%20set%20bureau-%25%25D%3C%2FEM%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1338493%22%20slang%3D%22fr-FR%22%3E%3CLINGO-LABEL%3EWindows%20PowerShell%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1338647%22%20slang%3D%22fr-FR%22%3ERe%3A%20Recovering%20the%20path%20from%20the%20%22Office%22%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1338647%22%20slang%3D%22fr-FR%22%3E%3CP%3ETo%20follow%20up%2C%3C%2FP%3E%3CP%3EThe%20order%3A%3C%2FP%3E%3CP%3E%3CEM%3EGet-ItemProperty%20-Path%20'HKCU%3A%20'Software'%2C%20Microsoft-Windows-CurrentVersion-Explorer-User%20Shell%20Folders'%20-Name%20desktop%3C%2FEM%3E%3C%2FP%3E%3CP%3EGives%20me%205%20settings%20of%20which%20the%20first%20one%20is%20the%20one%20I'm%20looking%20for%3A%20The%20path%20to%20the%20user's%20office.%3C%2FP%3E%3CP%3EI%20haven't%20figured%20out%20how%20to%20get%20it%20back%20yet.%3C%2FP%3E%3CP%3EIt's%20not%20going%20to%20be%20a%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1338669%22%20slang%3D%22fr-FR%22%3E%5BResolved%5D%20Re%3A%20Recovering%20the%20path%20from%20the%20%22Office%22%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1338669%22%20slang%3D%22fr-FR%22%3E%3CP%3ERe-Hello%20to%20all.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWell%20I%20found%20my%20solution.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ETo%20retrieve%20the%20path%20from%20the%20Active%20User's%20Office%20folder%3A%3C%2FP%3E%3CP%3E%24MonBureau%20-%20Get-ItemProperty%20-Path%20'HKCU%3A'Software'Microsoft'Windows'CurrentVersion'Explore'User%20Shell%20Folders'%20-Name%20desktop%20%3CBR%20%2F%3Eselect-object%20-ExpandProperty%20desktop%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%3CP%3EThanks%20to%20the%20contributors%20of%20this%20forum%20with%20whom%20I%20%22pumped%20and%20mixed%22%20the%20different%20responses%20to%20other%20concerns.%3C%2FP%3E%3CP%3EIt's%20not%20going%20to%20be%20a%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
New Contributor

Bonjour à toutes et tous.

Je suis débutant avec Powershell dans Windows 10. J'avais plutôt l'habitude des batch sous DOS :facepalm:

Le chemin d'accès des dossiers personnel est sujet à diverses modification d'emplacement. Chez moi ils sont tous dans le disque D: dans un dossier au nom de l'utilisateur.

D:\JC\Mes Documents, D:\JC\Mes Vidédos, D:\JC\Bureau, D:\JC\Ma Musique, etc...

Pour mon épouse c'est D:\Sylvie\Mes Documents, D:\Sylvie\Bureau, etc...

Idem pour mes enfants, etc...

 

Je cherche donc à récupérer dans une variable le chemin du Bureau en fonction de l'utilisateur qui utilise mes commandes Powershell

 

Exemple:

$MonBureau = 'D:\JC\Bureau'

systeminfo | Out-File $MonBureau\'Info_Système.txt'

Pour récupérer les info système dans un fichier texte du Bureau de JC $MonBureau .

 

Je ne sais pas où ni comment récupérer ce chemin du Bureau spécifique à chaque utilisateur dans ma variable.

 

Merci

A+

 

En batch DOS, je récupère le chemin dans la base de registre avec:

for /f "usebackq tokens=1,2,*" %%B IN (`reg query "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v Desktop`) do set bureau=%%D

 

 

2 Replies
Highlighted

Pour faire suite,

La commande :

Get-ItemProperty -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders' -Name desktop

Me donne 5 paramètres dont le 1er est celui que je cherche: Le chemin du Bureau de l'utilisateur.

J'ai pas encore trouvé comment le récupérer.

A+

Highlighted
Best Response confirmed by JCMacintosh (New Contributor)
Solution

Re-Bonjour à toutes et tous.

 

Bon j'ai trouvé ma solution.

 

Pour récupérer le chemin du dossier Bureau de l'utilisateur actif:

$MonBureau = Get-ItemProperty -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders' -Name desktop |
select-object -ExpandProperty desktop

Merci aux contributeurs de ce forum chez qui j'ai "pompé et mixé" les différentes réponses à d'autres préoccupations.

A+