آموزش ساخت Console Application ایجاد میانبر فایل و بکارگیری بعنوان دستور خارجی (External Command) در PowerShell و Command Prompt
Imports IWshRuntimeLibrary
Module Module1
Sub Main(ByVal Args() As String)
Dim Target As String = ""
Dim ShortcutPath As String = ""
Dim Description As String = ""
Console.WriteLine("{0}Length={2} ,{1}", vbTab, Join(Args, Space(1)), Args.Length)
If Args.Length Mod 2 <> 0 Then
Console.ForegroundColor = ConsoleColor.Red
Console.WriteLine("{0}Wrong Parameters for 'CreateShortcut' External Command!", vbTab)
Console.ResetColor()
Exit Sub
End If
Dim Expr As String = ""
Try
For i = 0 To Args.Length - 1 Step 2
Expr = Args(i + 1)
Select Case Args(i).ToLower
Case "-target"
Target = Expr
Case "-path"
ShortcutPath = Expr
Case "-comment"
Description = Expr
End Select
Next
Dim WSH As New WshShell
Dim Shortcut As WshShortcut = WSH.CreateShortcut(ShortcutPath)
With Shortcut
.TargetPath = Target
.Description = Description
.Save()
End With
Catch ex As Exception
Console.ForegroundColor = ConsoleColor.Red
Console.WriteLine("{0}{1}", vbTab, ex.Message)
Console.ResetColor()
End Try
End Sub
End Module