RunProgram() with a shortcut .lnk
RunProgram() with a shortcut .lnk
I have a shortcut link "myprogram.exe" which is actually "myprogram.exe.lnk", but RunProgram("myprogram.exe") returns 0, and RunProgram("myprogram.exe.lnk") returns 1 but does not run the shortcut like when I click it from explorer. Instead it launches 7-zip!??
Is there a trick to running shortcuts from RunProgram or am I missing something simple?
Thanks
Is there a trick to running shortcuts from RunProgram or am I missing something simple?
Thanks
That's very strange. I have a hotkey program I wrote which launches .lnk files just fine.
Try this as an alternative:
You should not have to do this though. Some antivirus programs will also issue an alert if another program tries to launch cmd.exe.
Try launching the program in quotes? I don't think this is the problem either.
Try this as an alternative:
Code: Select all
%comspec% /c c:\program_name.exe.lnk
Try launching the program in quotes? I don't think this is the problem either.
I tried:
But it gave an error that it could not find "%comspec%", so I changed it to "cmd.exe" and it now works fine.
Thanks for the tip.
Code: Select all
RunProgram("%comspec%","/c C:\myprogram.exe.lnk","c:\")
Thanks for the tip.
Code: Select all
RunProgram(GetEnvironmentVariable("COMSPEC"),"/c C:\myprogram.exe.lnk","c:\")
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.

Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.

- Kwai chang caine
- Always Here
- Posts: 5494
- Joined: Sun Nov 05, 2006 11:42 pm
- Location: Lyon - France
For info, i tried the line of TS-SOFT on W2000
I tried this on a shortcut Visual basic
At the beginning, it don't works
Then i say to me, it's the fault at BILL GATES
But no, it's the fault at KCC
Because i learn that this line, don't works, if the shortcut have a point and/or have a space.
Example don't works:
Example works:
UpperCase/LowerCase has not sensible

I tried this on a shortcut Visual basic

At the beginning, it don't works

Then i say to me, it's the fault at BILL GATES

But no, it's the fault at KCC
Because i learn that this line, don't works, if the shortcut have a point and/or have a space.
Example don't works:
Code: Select all
RunProgram(GetEnvironmentVariable("COMSPEC"),"/c C:\vb 6.lnk","c:\")
RunProgram(GetEnvironmentVariable("COMSPEC"),"/c C:\vb6.0.lnk","c:\")
Code: Select all
RunProgram(GetEnvironmentVariable("COMSPEC"),"/c C:\vb6.lnk","c:\")
RunProgram(GetEnvironmentVariable("COMSPEC"),"/c C:\VB6.lnk","c:\")
Code: Select all
vb6.lnk = VB6.lnk

Not a destination
Try the following:
You need to put program parameters with spaces or punctuation into doublequotes.
Code: Select all
RunProgram(GetEnvironmentVariable("COMSPEC"),"/c "+Chr('"')+"C:\vb 6.lnk"+Chr('"'),"c:\")
RunProgram(GetEnvironmentVariable("COMSPEC"),"/c "+Chr('"')+"C:\vb6.0.lnk"+Chr('"'),"c:\")
- Kwai chang caine
- Always Here
- Posts: 5494
- Joined: Sun Nov 05, 2006 11:42 pm
- Location: Lyon - France
Yes, you are right , thanks for this tipsmback2k wrote:Try the following:You need to put program parameters with spaces or punctuation into doublequotes.Code: Select all
RunProgram(GetEnvironmentVariable("COMSPEC"),"/c "+Chr('"')+"C:\vb 6.lnk"+Chr('"'),"c:") RunProgram(GetEnvironmentVariable("COMSPEC"),"/c "+Chr('"')+"C:\vb6.0.lnk"+Chr('"'),"c:")

Decidedly, i don't know if a day, i feel all the delicacy of the programming

You are right, i ask me the same question in my little head :roll:SFSxOI wrote:why bother to run it by activating a shortcut to begin with? Why not just run the application file directly?

Not a destination
Thanks for all the feedback.
To answer a couple questions: Windows 2000 for this particular instance.
To answer a couple questions: Windows 2000 for this particular instance.
Because the shortcut contains specific parameters. I have several .lnk files which all point to the same main exe but with different INI files specified as parameters. I also have a monitor program which manages those instances and sometimes needs to re-launch the main exe, so I just want the monitor app to relaunch the shortcut.SFSxOI wrote:why bother to run it by activating a shortcut to begin with? Why not just run the application file directly?
- Le Soldat Inconnu
- Enthusiast
- Posts: 306
- Joined: Wed Jul 09, 2003 11:33 am
- Location: France
Re: RunProgram() with a shortcut .lnk
i find solution
it's something totally crazy, viva microsoft !
you have to replace "\" by "\\" in shortcut path
like this, and it's work (on XP)
it's something totally crazy, viva microsoft !
you have to replace "\" by "\\" in shortcut path
like this, and it's work (on XP)
Code: Select all
File.s = "D:\PureBasic\Développements\Utilitaires\Barre & Menu\Barre & Menu.lnk"
RunProgram(ReplaceString(File, "\", "\\", 0, 3))
LSI