c# - Create Shortcut on desktop that calls PowerShell cmdlet -


i' trying create shortcut on desktop c# code, that

  1. opens powershell,
  2. imports mymodule.dll,
  3. clears screen,
  4. shows cmdlets of mymodule.dll.

after executing c#, shortcut appears on dektop, reason quotes set around whole shortcut.targetpath. after removing quotes manually, fine.

how prevent these quotes set?

my code:

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(); 

as commented petseral, use arguments property pass arguments executable:

shortcut.targetpath = @"%windir%\\system32\\windowspowershell\\v1.0\\powershell.exe"; shortcut.arguments = @"-noexit -command &{ import-module \\srv\ps\mymodule.dll;clear; get-command -module mymodule}"; 

Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -