The following code creates a LNK or PIF that can be a shortcut to a users desktop. It will only place one on the current user's desktop. It assumes that the current path is where QB.EXE (QB 4.5) and runs my Q-Basics Demo with the library option. Naturally you can change the paths to run anything with any program. VB Script needs Internet Explorer installed to run!:
DIM Qt AS STRING * 1 Qt = CHR$(34) 'create quotes in code ff% = FREEFILE OPEN "Desktop.VBS" FOR OUTPUT AS #ff% PRINT #ff%, "'CREATES DESKTOP SHORTCUT FOR CURRENT USER! CLICK ON FILE TO RUN!" PRINT #ff%, "'Place Shortcut in Q-Basics folder with QBASIC! Change paths if necessary!" PRINT #ff%, PRINT #ff%, "Set oWS = CreateObject(" + Qt + "WScript.Shell" + Qt + ")" PRINT #ff%, "sPath = oWS.CurrentDirectory" PRINT #ff%, "Set oEnv = oWS.Environment(" + Qt + "Process" + Qt + ")" PRINT #ff%, "sProfile = oEnv.Item(" + Qt + "UserProfile" + Qt + ")" PRINT #ff%, "sLinkFile = sProfile & " + Qt + "\Desktop\Q-Basics.LNK" + Qt 'desktop link PRINT #ff%, "Set oLink = oWS.CreateShortcut(sLinkFile)" PRINT #ff%, "oLink.TargetPath = sPath & " + Qt + "\QB.EXE" + Qt 'Target: PRINT #ff%, "oLink.Arguments = " + Qt + "/L /RUN Q-BASICS.BAS" + Qt 'parameters PRINT #ff%, "oLink.Description = " + Qt + "Q-Basics Demonstrator" + Qt 'Comment: PRINT #ff%, "oLink.IconLocation = sPath & " + Qt + "\QB-45.ICO, 0" + Qt 'Icon PRINT #ff%, "oLink.WindowStyle = " + Qt + "1" + Qt PRINT #ff%, "oLink.WorkingDirectory = sPath" 'folder path PRINT #ff%, "oLink.Save" CLOSE #ff% 'ASSUMES QB.EXE is in current folder! Edit as needed SCREEN 0 'IMPORTANT to keep Qbasic full screen programs from freezing! SHELL "CSCRIPT Desktop.vbs" 'QB shell to run. QB64 will need _HIDE SCREEN 12 'return to full screen mode of program The script can also be run without the logo information in QB64 by using: SHELL _HIDE "cscript //nologo Example.vbs" Here is a link to my BATch file that copies the QB64 compiled EXE file to the present folder path. It will NOT copy EXE files when the BAS file is in the QB64 folder! http://www.qb64.net/forum/index.php?topic=2206.msg20504#msg20504 Scroll down to bottom post. Ted
|
| Response Title | Author and Date |
| * Dunno if I ever said it, but this is a cool way. Thanks for sharing it. | Dav on Dec 29 |