I dunno why I decided to look into this

but I did and this is my solution to adding shortcut files (.lnk files) to windows from your DBPro code.
I have made 3 functions.
- Add_Shortcut_Desktop
- Add_Shortcut
- Add_Shortcut_Ex
Basically the first of the 3 add a shortcut to the current users desktop, The second function has a list of 16 special folder locations where a shortcut can be added and the last function you enter the exact location of where you want the .lnk file to be saved.
Add_Shortcut_Desktop
Function Add_Shortcut_Desktop( Name$ as string , FileLocation$ as string , IconLocation$ as string , FileDescription$ as string , WorkingDIR$ as string, ShortcutKeys$ as string )
quote as string : quote = chr$( 34 )
If File Exist("C:\Shortcut.vbs") then Delete File "C:\Shortcut.vbs"
Open To Write 1, "C:\Shortcut.vbs"
Write String 1, "set WshShell = WScript.CreateObject(" + quote + "WScript.Shell" + quote + ")"
Write String 1, "strDesktop = WshShell.SpecialFolders(" + quote + "Desktop" + quote + ")"
Write String 1, "set oShellLink = WshShell.CreateShortcut(strDesktop & " + quote + "\" + Name$ + ".lnk" + quote + ")"
Write String 1, "oShellLink.TargetPath = " + quote + FileLocation$ + quote
Write String 1, "oShellLink.WindowStyle = 1"
Write String 1, "oShellLink.Hotkey = " + quote + ShortcutKeys$ + quote
Write String 1, "oShellLink.IconLocation = " + quote + IconLocation$ + quote
Write String 1, "oShellLink.Description = " + quote + FileDescription$ + quote
Write String 1, "oShellLink.WorkingDirectory = " + quote + WorkingDIR$ + quote
Write String 1, "oShellLink.Save"
Close File 1
Execute File "C:\Shortcut.vbs", "", ""
wait 1000
If File Exist("C:\Shortcut.vbs") then Delete File "C:\Shortcut.vbs"
endFunction
Add_Shortcut
Function Add_Shortcut( Name$ as string , AddToLocation as integer , FileLocation$ as string , IconLocation$ as string , FileDescription$ as string , WorkingDIR$ as string, ShortcutKeys$ as string )
//////////////////////////////////////
// AddToLocation Parameter Number //
//////////////////////////////////////
// 1 - AllUsersDesktop //
// 2 - AllUsersStartMenu //
// 3 - AllUsersPrograms //
// 4 - AllUsersStartup //
// 5 - Desktop //
// 6 - Favorites //
// 7 - Fonts //
// 8 - MyDocuments //
// 9 - NetHood //
// 10 - PrintHood //
// 11 - Programs //
// 12 - Recent //
// 13 - SendTo //
// 14 - StartMenu //
// 15 - Startup //
// 16 - Templates //
//////////////////////////////////////
AddToLocation$ as string : AddToLocation$ = ""
select AddToLocation
case 1 : AddToLocation$ = "AllUsersDesktop" : endCase
case 2 : AddToLocation$ = "AllUsersStartMenu" : endCase
case 3 : AddToLocation$ = "AllUsersPrograms" : endCase
case 4 : AddToLocation$ = "AllUsersStartup" : endCase
case 5 : AddToLocation$ = "Desktop" : endCase
case 6 : AddToLocation$ = "Favorites" : endCase
case 7 : AddToLocation$ = "Fonts" : endCase
case 8 : AddToLocation$ = "MyDocuments" : endCase
case 9 : AddToLocation$ = "NetHood" : endCase
case 10 : AddToLocation$ = "PrintHood" : endCase
case 11 : AddToLocation$ = "Programs" : endCase
case 12 : AddToLocation$ = "Recent" : endCase
case 13 : AddToLocation$ = "SendTo" : endCase
case 14 : AddToLocation$ = "StartMenu" : endCase
case 15 : AddToLocation$ = "Startup" : endCase
case 16 : AddToLocation$ = "Templates" : endCase
endselect
quote as string : quote = chr$( 34 )
If File Exist("C:\Shortcut.vbs") then Delete File "C:\Shortcut.vbs"
Open To Write 1, "C:\Shortcut.vbs"
Write String 1, "set WshShell = WScript.CreateObject(" + quote + "WScript.Shell" + quote + ")"
Write String 1, "strDesktop = WshShell.SpecialFolders(" + quote + AddToLocation$ + quote + ")"
Write String 1, "set oShellLink = WshShell.CreateShortcut(strDesktop & " + quote + "\" + Name$ + ".lnk" + quote + ")"
Write String 1, "oShellLink.TargetPath = " + quote + FileLocation$ + quote
Write String 1, "oShellLink.WindowStyle = 1"
Write String 1, "oShellLink.Hotkey = " + quote + ShortcutKeys$ + quote
Write String 1, "oShellLink.IconLocation = " + quote + IconLocation$ + quote
Write String 1, "oShellLink.Description = " + quote + FileDescription$ + quote
Write String 1, "oShellLink.WorkingDirectory = " + quote + WorkingDIR$ + quote
Write String 1, "oShellLink.Save"
Close File 1
Execute File "C:\Shortcut.vbs", "", ""
wait 1000
If File Exist("C:\Shortcut.vbs") then Delete File "C:\Shortcut.vbs"
endFunction
Add_Shortcut_Ex
Function Add_Shortcut_Ex( Name$ as string , AddToLocation$ as string , FileLocation$ as string , IconLocation$ as string , FileDescription$ as string , WorkingDIR$ as string, ShortcutKeys$ as string )
quote as string : quote = chr$( 34 )
If File Exist("C:\Shortcut.vbs") then Delete File "C:\Shortcut.vbs"
Open To Write 1, "C:\Shortcut.vbs"
Write String 1, "set WshShell = WScript.CreateObject(" + quote + "WScript.Shell" + quote + ")"
Write String 1, "set oShellLink = WshShell.CreateShortcut(" + quote + AddToLocation$ + quote + " & " + quote + "\" + Name$ + ".lnk" + quote + ")"
Write String 1, "oShellLink.TargetPath = " + quote + FileLocation$ + quote
Write String 1, "oShellLink.WindowStyle = 1"
Write String 1, "oShellLink.Hotkey = " + quote + ShortcutKeys$ + quote
Write String 1, "oShellLink.IconLocation = " + quote + IconLocation$ + quote
Write String 1, "oShellLink.Description = " + quote + FileDescription$ + quote
Write String 1, "oShellLink.WorkingDirectory = " + quote + WorkingDIR$ + quote
Write String 1, "oShellLink.Save"
Close File 1
Execute File "C:\Shortcut.vbs", "", ""
wait 1000
If File Exist("C:\Shortcut.vbs") then Delete File "C:\Shortcut.vbs"
endFunction
The 3 commands require most of the same information :
Name$ - The name of the shortcut the user see's.
FileLocation$ - Where the actual application that the shortcut file is pointing to is saved.
IconLocation$ - The loction of the icon you wish the shortcut file to use.
FileDescription$ - The description of the file (This is displayed on mouse over).
WorkingDIR$ - The actual applications working directory.
ShortcutKeys$ - Keys the user can press to activate the shortcut (e.g. CTRL+SHIFT+P).
Here's an example of how to use each command
Add_Shortcut_Desktop( "DBPro-Paint-Desktop", "mspaint.exe", "mspaint.exe, 0", "Paint shortcut added by DBPro", "", "CTRL+SHIFT+P" )
Add_Shortcut( "DBPro-Paint", 5, "mspaint.exe", "mspaint.exe, 0", "Paint shortcut added by DBPro_ex", "", "CTRL+SHIFT+P" )
Add_Shortcut_Ex( "DBPro-Paint-Ex", "C:\Users\" + Windows Username$() + "\Desktop", "mspaint.exe", "mspaint.exe, 0", "Paint shortcut added by DBPro", "", "CTRL+SHIFT+P" )
and finally here's some code you can put into a DBPro file and run to see that it works. The code below will add three shortcuts to MS-Paint onto your desktop.
NOTE : I Use windows 7 and thus Add_Shortcut_Ex may not use the correct location to the desktop. (C:\Users\" + Windows Username$() + "\Desktop).
Also It uses the Windows Username$() from the matrix plugin coolection.
Add_Shortcut_Desktop( "DBPro-Paint-Desktop", "mspaint.exe", "mspaint.exe, 0", "Paint shortcut added by DBPro", "", "CTRL+SHIFT+P" )
Add_Shortcut( "DBPro-Paint", 5, "mspaint.exe", "mspaint.exe, 0", "Paint shortcut added by DBPro_ex", "", "CTRL+SHIFT+P" )
Add_Shortcut_Ex( "DBPro-Paint-Ex", "C:\Users\" + Windows Username$() + "\Desktop", "mspaint.exe", "mspaint.exe, 0", "Paint shortcut added by DBPro", "", "CTRL+SHIFT+P" )
end
Function Add_Shortcut( Name$ as string , AddToLocation as integer , FileLocation$ as string , IconLocation$ as string , FileDescription$ as string , WorkingDIR$ as string, ShortcutKeys$ as string )
//////////////////////////////////////
// AddToLocation Parameter Number //
//////////////////////////////////////
// 1 - AllUsersDesktop //
// 2 - AllUsersStartMenu //
// 3 - AllUsersPrograms //
// 4 - AllUsersStartup //
// 5 - Desktop //
// 6 - Favorites //
// 7 - Fonts //
// 8 - MyDocuments //
// 9 - NetHood //
// 10 - PrintHood //
// 11 - Programs //
// 12 - Recent //
// 13 - SendTo //
// 14 - StartMenu //
// 15 - Startup //
// 16 - Templates //
//////////////////////////////////////
AddToLocation$ as string : AddToLocation$ = ""
select AddToLocation
case 1 : AddToLocation$ = "AllUsersDesktop" : endCase
case 2 : AddToLocation$ = "AllUsersStartMenu" : endCase
case 3 : AddToLocation$ = "AllUsersPrograms" : endCase
case 4 : AddToLocation$ = "AllUsersStartup" : endCase
case 5 : AddToLocation$ = "Desktop" : endCase
case 6 : AddToLocation$ = "Favorites" : endCase
case 7 : AddToLocation$ = "Fonts" : endCase
case 8 : AddToLocation$ = "MyDocuments" : endCase
case 9 : AddToLocation$ = "NetHood" : endCase
case 10 : AddToLocation$ = "PrintHood" : endCase
case 11 : AddToLocation$ = "Programs" : endCase
case 12 : AddToLocation$ = "Recent" : endCase
case 13 : AddToLocation$ = "SendTo" : endCase
case 14 : AddToLocation$ = "StartMenu" : endCase
case 15 : AddToLocation$ = "Startup" : endCase
case 16 : AddToLocation$ = "Templates" : endCase
endselect
quote as string : quote = chr$( 34 )
If File Exist("C:\Shortcut.vbs") then Delete File "C:\Shortcut.vbs"
Open To Write 1, "C:\Shortcut.vbs"
Write String 1, "set WshShell = WScript.CreateObject(" + quote + "WScript.Shell" + quote + ")"
Write String 1, "strDesktop = WshShell.SpecialFolders(" + quote + AddToLocation$ + quote + ")"
Write String 1, "set oShellLink = WshShell.CreateShortcut(strDesktop & " + quote + "\" + Name$ + ".lnk" + quote + ")"
Write String 1, "oShellLink.TargetPath = " + quote + FileLocation$ + quote
Write String 1, "oShellLink.WindowStyle = 1"
Write String 1, "oShellLink.Hotkey = " + quote + ShortcutKeys$ + quote
Write String 1, "oShellLink.IconLocation = " + quote + IconLocation$ + quote
Write String 1, "oShellLink.Description = " + quote + FileDescription$ + quote
Write String 1, "oShellLink.WorkingDirectory = " + quote + WorkingDIR$ + quote
Write String 1, "oShellLink.Save"
Close File 1
Execute File "C:\Shortcut.vbs", "", ""
wait 1000
If File Exist("C:\Shortcut.vbs") then Delete File "C:\Shortcut.vbs"
endFunction
Function Add_Shortcut_Ex( Name$ as string , AddToLocation$ as string , FileLocation$ as string , IconLocation$ as string , FileDescription$ as string , WorkingDIR$ as string, ShortcutKeys$ as string )
quote as string : quote = chr$( 34 )
If File Exist("C:\Shortcut.vbs") then Delete File "C:\Shortcut.vbs"
Open To Write 1, "C:\Shortcut.vbs"
Write String 1, "set WshShell = WScript.CreateObject(" + quote + "WScript.Shell" + quote + ")"
Write String 1, "set oShellLink = WshShell.CreateShortcut(" + quote + AddToLocation$ + quote + " & " + quote + "\" + Name$ + ".lnk" + quote + ")"
Write String 1, "oShellLink.TargetPath = " + quote + FileLocation$ + quote
Write String 1, "oShellLink.WindowStyle = 1"
Write String 1, "oShellLink.Hotkey = " + quote + ShortcutKeys$ + quote
Write String 1, "oShellLink.IconLocation = " + quote + IconLocation$ + quote
Write String 1, "oShellLink.Description = " + quote + FileDescription$ + quote
Write String 1, "oShellLink.WorkingDirectory = " + quote + WorkingDIR$ + quote
Write String 1, "oShellLink.Save"
Close File 1
Execute File "C:\Shortcut.vbs", "", ""
wait 1000
If File Exist("C:\Shortcut.vbs") then Delete File "C:\Shortcut.vbs"
endFunction
Function Add_Shortcut_Desktop( Name$ as string , FileLocation$ as string , IconLocation$ as string , FileDescription$ as string , WorkingDIR$ as string, ShortcutKeys$ as string )
quote as string : quote = chr$( 34 )
If File Exist("C:\Shortcut.vbs") then Delete File "C:\Shortcut.vbs"
Open To Write 1, "C:\Shortcut.vbs"
Write String 1, "set WshShell = WScript.CreateObject(" + quote + "WScript.Shell" + quote + ")"
Write String 1, "strDesktop = WshShell.SpecialFolders(" + quote + "Desktop" + quote + ")"
Write String 1, "set oShellLink = WshShell.CreateShortcut(strDesktop & " + quote + "\" + Name$ + ".lnk" + quote + ")"
Write String 1, "oShellLink.TargetPath = " + quote + FileLocation$ + quote
Write String 1, "oShellLink.WindowStyle = 1"
Write String 1, "oShellLink.Hotkey = " + quote + ShortcutKeys$ + quote
Write String 1, "oShellLink.IconLocation = " + quote + IconLocation$ + quote
Write String 1, "oShellLink.Description = " + quote + FileDescription$ + quote
Write String 1, "oShellLink.WorkingDirectory = " + quote + WorkingDIR$ + quote
Write String 1, "oShellLink.Save"
Close File 1
Execute File "C:\Shortcut.vbs", "", ""
wait 1000
If File Exist("C:\Shortcut.vbs") then Delete File "C:\Shortcut.vbs"
endFunction
