CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2001
    Location
    County Durham, England
    Posts
    238

    Launching a Shortcut from VB

    With ref to my previous problem about displaying files I which I cannot work out I have the a listview with the filenames of shortcuts which are retrieved from the Start Menu.

    eg. C:\windows\Start Menu\Product Support\Payroll\Help Files\Printers.lnk

    or

    C:\windows\Start Menu\Product Support\Payroll\Web Links\Inland Revenue.url

    How do I launch these shortcuts, I have tried the Shell command and also the ShellExecute API Call but neither work ?

    API Used :

    Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

    and then called by :

    ShellExecute 0&, "Open", FilePS.Path & "\" & Item, 0, 0, SW_NORMAL

  2. #2
    Join Date
    Feb 2001
    Location
    PA
    Posts
    163
    For the URL:

    Dim ProcessID As Long
    'Path to a web browser and path to URL
    ProcessID = Shell("C:\Program Files\Internet Explorer\iexplore.exe C:\windows\Start Menu\Product Support\Payroll\Web Links\Inland Revenue.url", 1)

    For the lnk file

    Mak a .bat file called Printers.bat with the path to the lnk file and then execute the .lnk file from the batch file as follows:

    ProcessID = Shell("The path to printers.bat", 1)

  3. #3
    Join Date
    Feb 2001
    Location
    Stamford CT USA
    Posts
    2,167
    you can also use:
    "cmd.exe /c start <url/link>"

    for winme/9x, use command.exe instead of cmd.exe

    -Cool Bizs

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured