Indigo Rose Software

Professional Software Development Tools

 
+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 15 of 22
  1. #1
    Join Date
    Aug 2006
    Posts
    355

    Star As could access the command line of a shortcut?

    As could access the command line of a shortcut?

    thx!!

  2. #2
    Join Date
    Jan 2001
    Location
    Anderson Island, WA, USA
    Posts
    2,863
    Quote Originally Posted by Solmos View Post
    As could access the command line of a shortcut?

    thx!!
    I'm guessing you want to break down the properties of a .lnk file?

    Check here:
    http://wsh2.freeweb.hu/ch10b.html
    for some useful info -- you'd need to combine that with LuaCom
    http://www.icynorth.com/luacom/index.html

    If that doesn't get you going -- let me know and I'll give it a go in my spare time.
    -josh


    (Click here to contact me)
    Providing Independent Professional Consulting Services for
    IndigoRose products, World Wide.
    Located in -8:00 (-7:00 DST) GMT Timezone (Western United States)

  3. #3
    Join Date
    Aug 2006
    Posts
    355
    Yes, get shortcut properties

    needed, target shortcut and command line shorcut.

    please, create one example.

    very thanks

  4. #4
    Join Date
    Jan 2001
    Location
    Anderson Island, WA, USA
    Posts
    2,863
    Quote Originally Posted by Solmos View Post
    Yes, get shortcut properties

    needed, target shortcut and command line shorcut.

    please, create one example.

    very thanks
    Sorry -- I could have sworn wsh had a "getshortcut" method; but it doesn't... Let me try to figure something out for you... "stay tuned".

    -josh


    (Click here to contact me)
    Providing Independent Professional Consulting Services for
    IndigoRose products, World Wide.
    Located in -8:00 (-7:00 DST) GMT Timezone (Western United States)

  5. #5
    Join Date
    May 2006
    Posts
    5,380
    this may help

    Here's a quick console app to show how to do this from C#. You'll first need to add a reference to the 'Windows Script Host Object Model' to your project which should be listed on the COM tab of the AddReference dialog in VS.

    using System;
    using IWshRuntimeLibrary;

    namespace WshShortcutDemo
    {
    class Program
    {
    static void Main()
    {
    // enter full path to existing shortcut file in next line
    string linkPathName = @"c:\SomeShortcutFile.lnk";
    WshShell shell = new WshShell();
    IWshShortcut link = (IWshShortcut)shell.CreateShortcut(linkPathName);
    Console.WriteLine("Target path is {0}",link.TargetPath);
    Console.WriteLine("Working directory is {0}",link.WorkingDirectory);
    Console.ReadLine();
    }
    }
    }
    source:
    http://www.csharpfriends.com/Forums/...x?PostID=48404

    it seems you access the .lnk file by using the "CreateShortcut" method and access the "TargetPath" or "Arguments" by useing the properties
    Open your eyes to Narcissism, Don't let her destroy your life!!

  6. #6
    Join Date
    Jan 2001
    Location
    Anderson Island, WA, USA
    Posts
    2,863
    Quote Originally Posted by Solmos View Post
    Yes, get shortcut properties

    needed, target shortcut and command line shorcut.

    please, create one example.

    very thanks
    Here's a sample that works -- I knew wsh could do it... I just got thrown becuase it's only method was "CreateShortcut" not "GetShortcut".. Anyway; you'll need the LuaCOM plugin (as indicated previously)

    Code:
    local tFile = Dialog.FileBrowse(true, "open link", _DesktopFolder, "Link files (*.lnk)|*.lnk", "", ".lnk", false, true);
    
    if File.DoesExist(tFile[1]) then
      local oWSH = luacom.CreateObject("wscript.shell");
      local oShortCut = oWSH:CreateShortcut( tFile[1] ) ;
      local cPath = oShortCut.TargetPath;
      Dialog.Message("Target", tFile[1].."\r\n points to\r\n".. cPath );
      oShortCut = nil;
      oWSH = nil;
      collectgarbage();
    end


    (Click here to contact me)
    Providing Independent Professional Consulting Services for
    IndigoRose products, World Wide.
    Located in -8:00 (-7:00 DST) GMT Timezone (Western United States)

  7. #7
    Join Date
    May 2006
    Posts
    5,380
    and arguments

    Code:
    local tFile = Dialog.FileBrowse(true, "open link", _DesktopFolder, "Link files (*.lnk)|*.lnk", "", ".lnk", false, true);
    
    if File.DoesExist(tFile[1]) then
      local oWSH = luacom.CreateObject("wscript.shell");
      local oShortCut = oWSH:CreateShortcut( tFile[1] ) ;
      local cPath = oShortCut.TargetPath;
      local Args = oShortCut.Arguments
      Dialog.Message("Target", tFile[1].."\r\n points to\r\n".. cPath.."\r\n\r\nArguments: "..Args );
      oShortCut = nil;
      oWSH = nil;
      collectgarbage();
    end
    more info
    http://msdn2.microsoft.com/en-us/library/at5ydy31.aspx
    Open your eyes to Narcissism, Don't let her destroy your life!!

  8. #8
    Join Date
    Aug 2006
    Posts
    355
    jassing detec s good the targetshortcut, but not command line

    RizlaUK this code not work. If target shorcut contain command line, return nothing

    Quote Originally Posted by RizlaUK View Post
    and arguments

    Code:
    local tFile = Dialog.FileBrowse(true, "open link", _DesktopFolder, "Link files (*.lnk)|*.lnk", "", ".lnk", false, true);
    
    if File.DoesExist(tFile[1]) then
      local oWSH = luacom.CreateObject("wscript.shell");
      local oShortCut = oWSH:CreateShortcut( tFile[1] ) ;
      local cPath = oShortCut.TargetPath;
      local Args = oShortCut.Arguments
      Dialog.Message("Target", tFile[1].."\r\n points to\r\n".. cPath.."\r\n\r\nArguments: "..Args );
      oShortCut = nil;
      oWSH = nil;
      collectgarbage();
    end
    more info
    http://msdn2.microsoft.com/en-us/library/at5ydy31.aspx
    EDIT:

    work in this case:


    C:\Documents and setting\-user-\Deskcop\your.lnk

    return: real routhe and command line, work OK

    but in this case:

    C:\Documents and setting\-user-\Main menu\Programs\star\your.lnk

    return nothing, NOT work
    Last edited by Solmos; 03-23-2008 at 03:27 PM.

  9. #9
    Join Date
    May 2006
    Posts
    5,380
    it worked in my test, are you sure you selected the right file ?
    Open your eyes to Narcissism, Don't let her destroy your life!!

  10. #10
    Join Date
    Aug 2006
    Posts
    355
    work in one case, and fails in other case

  11. #11
    Join Date
    Jan 2001
    Location
    Anderson Island, WA, USA
    Posts
    2,863
    Quote Originally Posted by RizlaUK View Post
    it worked in my test, are you sure you selected the right file ?
    I was able to replicate his issue with one .lnk file I found...

    Trying to figure out what's going on with it....


    (Click here to contact me)
    Providing Independent Professional Consulting Services for
    IndigoRose products, World Wide.
    Located in -8:00 (-7:00 DST) GMT Timezone (Western United States)

  12. #12
    Join Date
    Jan 2001
    Location
    Anderson Island, WA, USA
    Posts
    2,863
    I don't know why; but on the link I replicate the 'failure' -- adding this line of code worked.

    I added it after the File.DoesExist() line

    Code:
    tFile[1] = File.GetShortName( tFile[1] );


    (Click here to contact me)
    Providing Independent Professional Consulting Services for
    IndigoRose products, World Wide.
    Located in -8:00 (-7:00 DST) GMT Timezone (Western United States)

  13. #13
    Join Date
    Aug 2006
    Posts
    355
    Quote Originally Posted by jassing View Post
    I don't know why; but on the link I replicate the 'failure' -- adding this line of code worked.

    I added it after the File.DoesExist() line

    Code:
    tFile[1] = File.GetShortName( tFile[1] );
    Yes, and this code work's

    thx!!

  14. #14
    Join Date
    Jan 2001
    Location
    Anderson Island, WA, USA
    Posts
    2,863
    Quote Originally Posted by Solmos View Post
    Yes, and this code work's

    thx!!
    You're welcome. The help file is great; but that one is just odd -- I just took a guess on the short file name to see if it would help -- and it did.

    I'll probably file a "bug report" on it tomorrow.


    (Click here to contact me)
    Providing Independent Professional Consulting Services for
    IndigoRose products, World Wide.
    Located in -8:00 (-7:00 DST) GMT Timezone (Western United States)

  15. #15
    Join Date
    Aug 2006
    Posts
    355
    NEW BUG

    on this shortcut:

    Code:
    Target= C:\WINDOWS\Installer\your.msi

    Bug: show message error:

    Code:
    attempt to index local 'oShortCut' (a nil value)

Similar Threads

  1. access 2000 run time
    By jennersc in forum AutoPlay Media Studio 4.0
    Replies: 0
    Last Post: 07-31-2003, 12:09 PM
  2. HOWTO: Create a Shortcut to an Internet URL
    By Support in forum Setup Factory 6.0 Knowledge Base
    Replies: 0
    Last Post: 10-29-2002, 02:07 PM
  3. HOWTO: Uninstall a Shortcut Created with Actions
    By Support in forum Setup Factory 6.0 Knowledge Base
    Replies: 0
    Last Post: 09-25-2002, 09:50 AM
  4. HOWTO: Create a Shortcut on the Desktop
    By Support in forum Setup Factory 6.0 Knowledge Base
    Replies: 0
    Last Post: 09-19-2002, 02:56 PM
  5. DOS Shortcut Properties
    By ScottWirt in forum Setup Factory 6.0
    Replies: 0
    Last Post: 08-01-2002, 08:07 AM

Posting Permissions

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