Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Jan 2007
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Naming of created desktop shortcut

    Any help would be appreciated. I am having a problem with this script:

    if( document.FullName == location.href ) {
    alert( "The file is untitled." );
    }
    else {
    WshShell = new ActiveXObject( "WScript.Shell" );
    strDesktop = WshShell.SpecialFolders("Desktop");
    ShellLink = WshShell.CreateShortcut(strDesktop + "\\" + (document.title) + ".lnk");
    ShellLink.TargetPath = location.href;
    ShellLink.WindowStyle = 1;
    ShellLink.Description = "Shortcut to My File";
    ShellLink.WorkingDirectory = strDesktop;
    ShellLink.Save();
    }


    The script seems to generally work fine. However, it seems that it will not create a shortcut on the desktop to some websites (the same ones all of the time). I will list a couple of them below:

    http://kodak.com/eknec/PageQuerier.j...requestid=6711
    http://www.szgoto.com/doce/products_new.htm


    ...and then there is the case, like the one below, that one page will create a shortcut and another will not...

    This will: http://www.lockergnome.com/nexus/win...+in+new+window
    This will not: http://www.lockergnome.com/nexus/win...ls-blog-posts/

    ...and one more scenario -- two different sites create the same shortcut, thus the new shortcut replaces the old one...example below...

    http://goto.manufacturer.globalsourc...iffsupp=prodL4
    http://goto.manufacturer.globalsourc...anyProfile.htm

    Again, any help would be appreciated. Thank you.

  • #2
    Senior Coder
    Join Date
    Nov 2006
    Posts
    1,000
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Again, I believe it is illegal characters in a windows file name. You need to replace or get rid of the illegal characters. If you wonder what is illegal try changing the name of an icon on your desktop. When I do that I get

    A file cannot contain any of the following characters:
    \ / : * ? " < > |

    If you look at the document title for the kodak link you'll notice it has a | in it. Some of the other document titles look like they might be unicode which I don't believe windows can handle either.

    Try this code to see if it lets you mark the kodak site.

    Code:
    if( document.FullName == location.href ) {
    alert( "The file is untitled." );
    }
    else {
    WshShell = new ActiveXObject( "WScript.Shell" );
    strDesktop = WshShell.SpecialFolders("Desktop");
    sName = document.title;
    sName = sName.replace(/[^\w\d\s]/g, "");
    if (sName.length > 30) sName = sName.substring(0, 60);
    ShellLink = WshShell.CreateShortcut(strDesktop + "\\" + (sName) + ".lnk");
    ShellLink.TargetPath = location.href;
    ShellLink.WindowStyle = 1;
    ShellLink.Description = "Shortcut to My File";
    ShellLink.WorkingDirectory = strDesktop;
    ShellLink.Save();
    }
    I don't know if that will be enough for all the pages but it might help.

    david_kw

  • #3
    New Coder
    Join Date
    Jan 2007
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you david_kw. Yes, that fixed most of the problems. The changes had no effect on the one that created the same shortcut for two different websites. I think that is because the length limitation.


  •  

    Posting Permissions

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