0
我想在桌面上创建的C#代码上的快捷方式创建快捷方式,即在桌面上调用PowerShell命令
- 打开PowerShell中,
- 进口
myModule.dll
, - 清屏,
- 显示我所有的命令为
myModule.dll
。
执行C#之后,快捷方式出现在dektop上,但由于某种原因引号设置在整个shortcut.TargetPath
的周围。手动删除这些引号后,一切都很好。
如何防止设置这些引号?
我的代码:
object shDesktop = (object)"Desktop";
WshShell shell = new WshShell();
string shortcutAddress = (string)shell.SpecialFolders.Item(ref shDesktop) + @"\´MyModule.lnk";
IWshShortcut shortcut = (IWshShortcut)shell.CreateShortcut(shortcutAddress);
shortcut.Description = "MyModule";
shortcut.TargetPath = @"%Windir%\\system32\\WindowsPowerShell\\v1.0\\powershell.exe -noexit -command &{ import-module \\srv\PS\MyModule.dll;clear; get-command -Module MyModule}";
shortcut.Save();
'shortcut.Arguments' – PetSerAl
就是这样。 thx PetSerAl。 – piccus