0

当我尝试创建一个新的符号链接链接并将目标(值)路径设置为字符串“%UserProfile%\dir1\dir2\file.ext”时,生成的路径前面会加上运行脚本的目录。

$targetpath = '%UserProfile%\dir1\dir2\filename.ext'
New-Item -Path $currpath -ItemType SymbolicLink -Value ($targetpath) -Force

因此,如果我从 c:\scripts\ 运行脚本,值将变为 c:\scripts%UserProfile%\dir1\dir2\filename.ext。有人知道解决这个问题的方法吗?我可以修改现有的符号链接以使用此路径,它按预期运行,但似乎无法以编程方式执行此操作。

注意: MkLink 和 comobject.createshortcut 表现出相同的行为。

4

0 回答 0