(好的 - 我仍然收到一个错误)
天哪为什么会这样?我需要做的就是在一行中执行this。 像这样:
PS C:\Users\Horn.Ruben> $shell = New-Object -com "WScript.Shell"; $TestBackupAddin = $shell.CreateShortcut("C:\ClusterStorage\Volume2\test.lnk"); $TetsBackupAddin.TargetPath = "C:\ClusterStorage\Volume2\_VMBackups\20150113-0844\TestBackupAddin"; $TestBackupAddin.Save();
现在唯一的错误是:
The property 'TargetPath' cannot be found on this object. Verify that the property exists and can be set.
At line:1 char:123
+ $shell = New-Object -com "WScript.Shell"; $TestBackupAddin = $shell.CreateShortc ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : PropertyNotFound
在我使用它之前,两个目录是否都需要存在?
PS:我需要在一行中运行所有这些(后面会创建多个快捷键)
答案 0 :(得分:2)
尝试
$shell = New-Object -ComObject WScript.Shell
而不是
$shell = New-Object -ComObjetct WScript.Shell
答案 1 :(得分:1)
尝试
$TestBackupAddin = $shell.CreateShortcut
而不是
$TetsBackupAddin = $shell.CreateShortcut