' make-shortcut.vbs <targetExe> <name> <workingDir>
' Creates Start Menu (all users) and desktop shortcuts. VBScript so the same
' helper works on Windows XP (no PowerShell) and Windows 10/11.
Option Explicit
Dim shell, fso, target, name, workdir, places, place, lnk
If WScript.Arguments.Count < 3 Then
    WScript.Echo "usage: make-shortcut.vbs <targetExe> <name> <workingDir>"
    WScript.Quit 1
End If
target = WScript.Arguments(0)
name = WScript.Arguments(1)
workdir = WScript.Arguments(2)

Set shell = CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")

places = Array(shell.SpecialFolders("AllUsersPrograms"), shell.SpecialFolders("Desktop"))
For Each place In places
    If fso.FolderExists(place) Then
        Set lnk = shell.CreateShortcut(fso.BuildPath(place, name & ".lnk"))
        lnk.TargetPath = target
        lnk.WorkingDirectory = workdir
        lnk.Description = "RIOJoy cockpit interface"
        lnk.Save
        WScript.Echo "  shortcut: " & fso.BuildPath(place, name & ".lnk")
    End If
Next
