将Desktop文件夹重新定位到OneDrive后,%USERPROFILE%/ Desktop不再有效 [英] %USERPROFILE%/Desktop no longer valid after relocating Desktop folder to OneDrive
本文介绍了将Desktop文件夹重新定位到OneDrive后,%USERPROFILE%/ Desktop不再有效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
由于OneDrive同步,我已将Windows / Desktop文件夹移至其他位置。
I've moved my Windows /Desktop folder to a different location, due to OneDrive sync.
结果是,指向%USERPROFILE%/ Desktop
的批处理脚本和Powershell脚本不再起作用。
As a result, my batch and Powershell scripts that were pointing to %USERPROFILE%/Desktop
no longer worked. Is there another way to get the location of my desktop without hardcoding the new path in?
推荐答案
在PowerShell中,您可以使用此
In PowerShell you can use this
[Environment]::GetFolderPath([Environment+SpecialFolder]::Desktop)
要从批处理文件中使用它,可以调用powershell来获取路径
To use it from a batch file you can call powershell to get the path
powershell -Com "[Environment]::GetFolderPath([Environment+SpecialFolder]::Desktop)"
,然后使用 用于/ f
and then save the result to a variable using for /f
这篇关于将Desktop文件夹重新定位到OneDrive后,%USERPROFILE%/ Desktop不再有效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文