[Release] Create A Desktop Shortcut With A Press Of A Button

General questions about scripts and buttons should be asked here. Development scripts and buttons may also be posted for feedback.

Moderators: Support Staff², Support Staff, AvantGuard, Developer

Post Reply
Scrabble
Semi-Fan
Semi-Fan
Posts: 68
Joined: Sat Nov 18, 2006 10:36 pm
Windows Version: Windows
Avant Version:

[Release] Create A Desktop Shortcut With A Press Of A Button

Post by Scrabble » Thu Feb 15, 2007 4:13 am

You can create a desktop shortcut to a website with a press of a button by going to Tools...Avant Browser Options...Add-Ons...Add-Ons. Then click add, give it a name, select an icon to identify it, make sure for "Type" that the 'Script Button' is selected, then paste the text below into the 'Content' field:


var visitor_name = prompt("Enter the shortcut name:",(location.href, document.title));
if (visitor_name!=null)
if( document.FullName == location.href ) {
alert( "The file is untitled." );
}
else {
WshShell = new ActiveXObject( "WScript.Shell" );
strDesktop = WshShell.SpecialFolders("Desktop");
sName = (visitor_name);
sName = sName.replace(/[^\w\d\s]/g, "-");
ShellLink = WshShell.CreateShortcut(strDesktop + "\\" + (sName) + ".lnk");
ShellLink.TargetPath = location.href;
ShellLink.WindowStyle = 1;
ShellLink.Description = "Shortcut to My File";
ShellLink.WorkingDirectory = strDesktop;
ShellLink.Save();
}


If you would rather a name did not auto-populate in the 'Enter the shortcut name' field then just change the first line to:

var visitor_name = prompt("Enter the shortcut name:","");


If you don't have any icons available to assign to this script, I suggest downloading EasyPicture2Icon to create them. It's free.

Scrabble
Semi-Fan
Semi-Fan
Posts: 68
Joined: Sat Nov 18, 2006 10:36 pm
Windows Version: Windows
Avant Version:

Post by Scrabble » Thu Feb 15, 2007 4:39 am

If you want to create a shortcut without any prompt popping up, then use the script below:

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, "-");
ShellLink = WshShell.CreateShortcut(strDesktop + "\\" + (sName) + ".lnk");
ShellLink.TargetPath = location.href;
ShellLink.WindowStyle = 1;
ShellLink.Description = "Shortcut to My File";
ShellLink.WorkingDirectory = strDesktop;
ShellLink.Save();
}

User avatar
Sati
Newbie
Newbie
Posts: 2
Joined: Fri Aug 03, 2007 11:30 am
Windows Version: Window XP Pro
Avant Version: 11.5 Build 21
IE Version: 7.0.5730.11
Location: Sweden

Re: [Release] Create A Desktop Shortcut With A Press Of A Button

Post by Sati » Tue Mar 04, 2008 3:10 pm

I created the script, however I don't see how to use it. Is a button or addition to a drop-down menu hiding from me somewhere? Thank you!
Holly ~

User avatar
hornakapopolis
AvantGuard
AvantGuard
Posts: 11321
Joined: Thu Jul 31, 2003 2:09 pm
Windows Version: Windows 10 Pro 64
Avant Version: 2015
Default engine: Chrome
IE Version: 11
Skin: Stickers
Location: Ohio, USA
Contact:

Re: [Release] Create A Desktop Shortcut With A Press Of A Button

Post by hornakapopolis » Tue Mar 04, 2008 3:23 pm

You're going to have to be showing the Add-on Buttons bar from the View -> Toolbars menu and you'll also have to create use an icon file for it to use as a button.

User avatar
Sati
Newbie
Newbie
Posts: 2
Joined: Fri Aug 03, 2007 11:30 am
Windows Version: Window XP Pro
Avant Version: 11.5 Build 21
IE Version: 7.0.5730.11
Location: Sweden

Re: [Release] Create A Desktop Shortcut With A Press Of A Button

Post by Sati » Tue Mar 04, 2008 3:47 pm

Doh, perfect! Thank you :)
Holly ~

abfan123
Avantus Maximus
Avantus Maximus
Posts: 5624
Joined: Wed Jan 26, 2005 4:24 pm
Windows Version: Vista Ultimate x64 SP2
Avant Version: 11.7 build 43
IE Version: 8
Contact:

Re: [Release] Create A Desktop Shortcut With A Press Of A Button

Post by abfan123 » Tue Mar 04, 2008 4:19 pm

Great script, But unfortunately, IE security settings should be altered for it to work properly.
Thanks anyway!
IE8(Pro), Microsoft Security Essentials
Main PC:
Image
Secondary PC same as primary but with Windows 7 x64 Ultimate as the OS.

Post Reply