As could access the command line of a shortcut?
thx!!
Professional Software Development Tools
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)
Yes, get shortcut properties
needed, target shortcut and command line shorcut.
please, create one example.
very thanks
(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)
this may help
source: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();
}
}
}
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!!
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)
and arguments
more infoCode: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
http://msdn2.microsoft.com/en-us/library/at5ydy31.aspx
Open your eyes to Narcissism, Don't let her destroy your life!!
jassing detec s good the targetshortcut, but not command line
RizlaUK this code not work. If target shorcut contain command line, return nothing
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.
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!!
work in one case, and fails in other case![]()
(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)
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)
(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)
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)