WULover Posted June 2, 2023 Share Posted June 2, 2023 (edited) Hello! I have a big issue in Visual Basic. When I create a shortcut on the desktop using a small program in Visual Basic 5.0 on Windows 98, the shortcut have its target on the previous folder (ex: C:\Program Files\ovtxt_xp_run.exe instead of C:\Program Files\OverRender OverText XP\ovtxt_xp_run.exe | you can see that the "OverRender OverText XP" folder is missing in the target. Here's the code in VB 5.0: ' Programme de création du raccourci d'OverRender OverText XP dans le dossier de l'application ' This program is a part of the OverRender OverText XP Setup. ' ' 2023 - OverRender.com ' Processus de création du raccourci Private Sub cmdMakeLNKFile() Dim Shell As WshShell Dim Shortcut As WshShortcut Dim DesktopDir As String ' Initialiser l'objet WshShell Set objShell = New WshShell ' Initialiser l'objet ObjShortcut 'the complete name of the .lnk file, include full path plus the .LNK file extension Set objshortcut = objShell.CreateShortcut(App.Path + "/OverRender OverText XP.lnk") ' Définir la cible du raccourci objshortcut.TargetPath = App.Path + "/ovtxt_xp_run.exe" ' Définir l'icône du raccourci objshortcut.IconLocation = App.Path + "/softassets/ovtexticon.ico" ' Définir le commentaire / la description du raccourci objshortcut.Description = "Create, open, edit and share documents easily by using OverRender OverText XP." ' Sauvegarder le raccourci créé objshortcut.Save MsgBox (App.Path) End Sub ' Exécution de la tâche "cmdMakeLNKFile" lors du lancement du programme. ' A noter : le programme est invisible. Private Sub Form_Load() Call cmdMakeLNKFile 'MsgBox (DesktopPath) End End Sub (do not worry about the comments in French, you can always translate them). Could anyone help me with that please? I have that since now 1 year and it's very annoying, as shortcuts are made to make the access to the program easy and not hard. Thank you! Edited June 2, 2023 by WULover Link to comment Share on other sites More sharing options...
jumper Posted June 2, 2023 Share Posted June 2, 2023 (edited) You hardcoded the exe filename, but not the path you want. It looks like you are running the test program (directly or via a shortcut) from "C:\Program Files" so that folder alone is used in the Target path. If from a shortcut, check the "Start in" folder specified there. Edited June 2, 2023 by jumper Link to comment Share on other sites More sharing options...
WULover Posted June 2, 2023 Author Share Posted June 2, 2023 (edited) The path is not fixed, and is setup up when running the setup. Could you explain what you meant please ? Also, what code should I add/change/remove from the existing one? The name of my .exe is the same for everyone, so it has to be hardcoded. Can you provide an example too please (I'm asking a lot but I do not really know how to code in VB 5.0). Thank you ! Edited June 2, 2023 by WULover Link to comment Share on other sites More sharing options...
jumper Posted June 2, 2023 Share Posted June 2, 2023 3 hours ago, WULover said: MsgBox (App.Path) What is this telling you? And when you run it from different location? Link to comment Share on other sites More sharing options...
WULover Posted June 6, 2023 Author Share Posted June 6, 2023 This was telling me the application path. And I found the solution to my problem, thx for helping Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now