Creating lnk shortcuts that has different names than the original file?

  • Thread starter Thread starter xanrer
  • Start date Start date
X

xanrer

Guest
What im trying to do here is:

Getting a name for the shortcut file.
Then getting the path of the original file and the files name and extension itself.
Then saving the shortcut as the name i gave to it.

(using IWshRuntimeLibrary)


string scLoc = AppDomain.CurrentDomain.BaseDirectory + @"\shortcuts";
string typed = null;
while (true)
{
string regName = null;
Console.WriteLine();
inputedKey = Console.ReadKey(true);
else if (char.ToLower(inputedKey.KeyChar) == 'l')
{
Console.WriteLine("\nPlease choose the name of the registary:\n");
regName = Console.ReadLine();
regName = regName + ".lnk";
Console.WriteLine("\nPlease enter the original file name and path as like this example \"X:\\Folder\\Program.ext\":\n");
typed = Console.ReadLine();
if (System.IO.File.Exists(typed) == false)
{
Console.WriteLine("File does not exist");
continue;
}
else
{
WshShell shell = new WshShell();
IWshShortcut shortcut = (IWshShortcut)shell.CreateShortcut(typed);
shortcut.TargetPath = scLoc;
Console.WriteLine("\nDone!");
Console.ReadKey(true);
break;
}
}
}
break;
Whats the problem and how can i fix it?

Continue reading...
 
Back
Top