|
Post by sarmednafi on Apr 3, 2024 14:00:14 GMT -5
Dear Group,
I just finished a simple setup program, unfortunately I don't know how to create a Short Cut via Liberty Basic code to put it on desktop. Any one knows? I will appreciate such help very much.
The target to create shortcut for it: C:\Program Files (x86)\MyFolder\MyProgram.exe
Regards Sarmed Nafi'
|
|
|
Post by metro on Apr 3, 2024 19:31:18 GMT -5
Dear Group, I just finished a simple setup program, unfortunately I don't know how to create a Short Cut via Liberty Basic code to put it on desktop. Any one knows? I will appreciate such help very much. The target to create shortcut for it: C:\Program Files (x86)\MyFolder\MyProgram.exe Regards Sarmed Nafi' I have not used any of this, Newsletters 119 & 120 cover it.
|
|
|
Post by sarmednafi on Apr 4, 2024 2:59:33 GMT -5
Thank you metro, There is no Newsletters 119, 120 on the net the limit is to 111. All the best
Sarmed
|
|
|
Post by Rod on Apr 4, 2024 6:02:55 GMT -5
This is the .exe that you need , everything else is in Metro's zip Shortcut.zip (23.11 KB)
|
|
|
Post by xxgeek on Apr 4, 2024 6:59:01 GMT -5
The .bas provided has an error in this line. open "user" for dll as #user should be? open "user32.dll" for dll as #user maybe? Seems to work for Windows 10
There is another way with less code, and no 3rd party exe to download. Have the program write a Visual Basic script and run it.
The following code, when RUN(after saving), opens with a filedialog to select a file. Then creates a shortcut on the desktop to that file. Edit to your liking.
'Make Desktop Shortcut using VB Script 'by xxgeek 'Nov 2023 'an example to edit/use in code to create desktop shorcuts
'this example assumes a 3 character file extension 'Save to file before RUN'ning nomainwin global filepath$, shortCutName$ 'comment & uncomment next 2 lines - use your own filepath$ filedialog "Select File to Create Shorcut on Desktop", DefaultDir$;"\*.*", filepath$ 'shortcut to this file will be placed on your desktop 'filepath$ = "Path\to\YourFile.xxx" if filepath$ <> "" then i = len(filepath$) while mid$(filepath$, i, 1) <> "\" and mid$(filepath$, i, 1) <> "" i = i-1 wend nameOffile$ = mid$(filepath$, i+1) 'name the shortcut (appears as text on shortcut) - assumes extension is . + 3 characters shortCutName$ = "Shortcut to ";left$(nameOffile$, len(nameOffile$)-4) 'Don't use "Shortcut to " at beginning of name if desired 'shortCutName$ = left$(nameOffile$, len(nameOffile$)-4) call MDS end if end
'Make Desktop Shortcut - Using Visual Basic Script 'write/run a short .vbs script to create a desktop shortcut to the selected file sub MDS q$=chr$(34) desktopShortcut$ = "desktopShortcut.vbs" open desktopShortcut$ for output as #1 #1 "Set Shell = CreateObject(";q$;"WScript.Shell";q$;")" #1 "DesktopPath = Shell.SpecialFolders(";q$;"Desktop";q$;")" #1 "Set link = Shell.CreateShortcut(DesktopPath & ";q$;"\";shortCutName$;".lnk";q$;")" #1 "link.Description = ";q$;shortCutName$;" ";filepath$;q$ '#1 "link.HotKey = ";q$;"CTRL+ALT+E";q$ 'setup a hotkey Link option #1 "link.TargetPath = ";q$;filepath$;q$ #1 "link.WindowStyle = 3" #1 "link.Save" #1 "Set link = nothing" #1 "Set Shell = nothing" close #1 run "wscript ";desktopShortcut$ end sub
|
|
|
Post by sarmednafi on Apr 4, 2024 19:56:51 GMT -5
Rod,
Thanks for the exe you sent.
Xxgeek,
Thanks a lot, your code is power full. It is a great help, All the best. Thank you very much.
Sarmed N.
|
|
|
Post by xxgeek on Apr 5, 2024 13:25:27 GMT -5
Xxgeek, Thanks a lot, your code is power full. It is a great help, All the best. Thank you very much. Sarmed N. You're welcome sarmednafi Note: You can swap out the following line in the 'Sub MDS' #1 "DesktopPath = Shell.SpecialFolders(";q$;"Desktop";q$;")" with #1 "DesktopPath = Shell.SpecialFolders(";q$;"StartMenu";q$;")" to add the shortcut to the Start Menu instead of the Desktop. In fact there are many "Special Folders" that can be swapped into that line. There is a long list of them, and their appropriate Windows Operating System At This AddressI've used 'SendTo' to add Notepad, JB and LB to my 'SendTo" right click menu. That way I can right click a file (.txt .bas .anything), and send it to one of those apps depending on my reason for opening the file. I check a lot of files with notepad just to see if I notice anything odd in the text, or the gobblygook. regards xxgeek
|
|
|
Post by sarmednafi on Apr 5, 2024 23:08:50 GMT -5
Thank you Geek, That's wonderful.
|
|