[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

BeeJ

4/2/2012 11:09:00 PM

I have been trying to execute stuff.
I can execute a .COM or .EXE with or without command parameters.

No, I do not want to use associations for this.
The command is explicit as to what app to open and what params (if any)
are used.

e.g. NotePad.exe ' the system knows where this is so path not needed.
"C:\Program Files\Windows NT\Accessories\wordpad.exe" ' path needed

1) command only, use as is
2) command only with embedded spaces, add "" fore and aft.
3) command with arguments (add "" if spaces in command), add a space
between command and arguments.

I cannot figure out how to execute a .LNK

e.g. "C:\Documents and Settings\Administrator\Desktop\WordPad.lnk"

Perhaps because I think I can optionally add command parameters to
this.
Does a .LNK allow command parameters?

All I could find from Googling was a lot of confusion.
I tried many diferent snippets but none worked.

So how do I do a general case or at least how do I do .lnk (I can check
for extension (COM & EXE) and filter).

Do I have to open the .LNK file and extract stuff from it to use? How?

I do not need to wait for the app to execute but would like to know if
it made it open.

I have been trying these three:

' returns zero if fails otherwise return process ID
vRtn = Shell(sThis, lVBAppWinStyle)

=========

If shlShell Is Nothing Then
Set shlShell = New shell32.Shell

End If
shlShell.Open sCmdLine
DoEvents

========

ShellTo = ShellExecute(0&, x, , , , SW_SHOWNORMAL)

--
Noah's Ark was built by amateurs,
The Titanic was built by professionals.
Row, row, row your boat gently down the stream ...
Life is but a dream!


6 Answers

Karl E. Peterson

4/3/2012 12:41:00 AM

0

BeeJ formulated on Monday :
> I cannot figure out how to execute a .LNK

Weren't you asking, not all that long ago, how to read/write to these
critters? I remember, because you weren't aware of the tool that came
on the VB5/6 CDs.

Dereference it. Execute what it points to. Sheesh...

--
..NET: It's About Trust!
http://vfre...


Dee Earley

4/3/2012 7:51:00 AM

0

On 03/04/2012 00:08, BeeJ wrote:
> I have been trying to execute stuff.
> I can execute a .COM or .EXE with or without command parameters.
>
> No, I do not want to use associations for this.
> The command is explicit as to what app to open and what params (if any)
> are used.
>
> e.g. NotePad.exe ' the system knows where this is so path not needed.
> "C:\Program Files\Windows NT\Accessories\wordpad.exe" ' path needed
>
> 1) command only, use as is
> 2) command only with embedded spaces, add "" fore and aft.
> 3) command with arguments (add "" if spaces in command), add a space
> between command and arguments.
>
> I cannot figure out how to execute a .LNK
>
> e.g. "C:\Documents and Settings\Administrator\Desktop\WordPad.lnk"
>
> Perhaps because I think I can optionally add command parameters to this.
> Does a .LNK allow command parameters?

You need ShellExecute to run .lnk file, and any command line parameters
are passed to the target program.
If you want to pass parameters via ShellExecute, you need to split into
path and parameters.

--
Deanna Earley (dee.earley@icode.co.uk)
i-Catcher Development Team
http://www.icode.co.uk...

iCode Systems

(Replies direct to my email address will be ignored.
Please reply to the group.)

ObiWan

4/3/2012 1:43:00 PM

0

> > I cannot figure out how to execute a .LNK
>
> Weren't you asking, not all that long ago, how to read/write to these
> critters? I remember, because you weren't aware of the tool that
> came on the VB5/6 CDs.
>
> Dereference it. Execute what it points to. Sheesh...

or either call it through the command processor (%COMSPEC% /c
foobar.lnk)

BeeJ

4/3/2012 4:28:00 PM

0

I was hoping for a one liner API to open the .LNK
But now I am going to rip open the .LNK and get all the parameters and
shell path+args that way.


Karl E. Peterson

4/3/2012 5:30:00 PM

0

ObiWan presented the following explanation :
>>> I cannot figure out how to execute a .LNK
>>
>> Weren't you asking, not all that long ago, how to read/write to these
>> critters? I remember, because you weren't aware of the tool that
>> came on the VB5/6 CDs.
>>
>> Dereference it. Execute what it points to. Sheesh...
>
> or either call it through the command processor (%COMSPEC% /c
> foobar.lnk)

Nice! That's gotta be the easiest method possible, if you know you
want to use all the properties (including parameters) of the LNK.

--
..NET: It's About Trust!
http://vfre...


ralph

4/3/2012 8:31:00 PM

0

On Tue, 03 Apr 2012 09:27:59 -0700, BeeJ <nospam@spamnot.com> wrote:

>I was hoping for a one liner API to open the .LNK
>But now I am going to rip open the .LNK and get all the parameters and
>shell path+args that way.
>

A .LNK file is NOT an executable. One needs to use a shell interpreter
to launch ("open"?) one, either the Windows Shell or the Command Line
parser will do. [VB's Shell() executes the latter.]

Other showed you how to do that.

Since you wanted to know if the command succeeds then
ShellExecuteWait() should be satisfactory.

A link file is essentially a short-cut for a Shell to save typing by
packaging lengthy command strings, allowing 'drag 'n drop', and a
single thingy to 'click' within a single file. They can be used to
package practically anything - executables, documents, folders, links,
.... . They can exhibit polymorphic behavior by defining "verbs" and
passing that to the link via the ShellExecute/Wait().

..LNK files are a tad notorious, in that they can be easily corrupted,
often deleted, occasionally out-of-date, often found in assorted
locations. [Most of them are back-upped in the Registry, but without
deliberating running a tool there is no guarantee the Registry and
current .lnk files are in synch.]

Considering the specificity of their design and application, and how
easy it is to launch, create, and then use, (or mess one up <g>), and
how easy it is to retrieve information from other likely more reliable
sources, it is difficult to understand why anyone would feel the need
to "rip" one open?

What is the 'real' issue?

-ralph