Saturday 2 February 2013

Creating Shortcut using JavaScript



WindowStyle Property:
intWindowStyle
Description
1
Activates and displays a window. If the window is minimized or maximized, the system restores it to its original size and position.
3
Activates the window and displays it as a maximized window.
7
Minimizes the window and activates the next top-level window.

SpecialFolders:
Identifier
Folder Contents
AllUsersDesktop
Shortcuts that appear on the desktop for all users
AllUsersStartMenu
Shortcuts that appear on the Start menu for all users
AllUsersPrograms
Shortcuts that appear on the Programs menu for all users
AllUsersStartup
Shortcuts to programs that are run on startup for all users
Desktop
Shortcuts that appear on the desktop for the current user
Favorites
Shortcuts saved as favorites by the current user
Fonts
Fonts installed on the system
MyDocuments
Current users documents
NetHood
Objects that appear in Network Neighborhood
PrintHood
Printer links
Recent
Shortcuts to current users recently opened documents
SendTo
Shortcuts to applications that show up as possible send-to targets when a user right-clicks on a file in Windows Explorer
StartMenu
Shortcuts that appear in the current users start menu
Startup
Shortcuts to applications that run automatically when the current user logs on to the system
Templates
Application template files specific to the current user

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
    <head>
        <title>Creating Shortcut</title>
        <script type="text/javascript">
            function createShortcut() {
                var WshShell = new ActiveXObject("WScript.Shell");
                var strDesktop = WshShell.SpecialFolders("Desktop");
                var oShellLink = WshShell.CreateShortcut(strDesktop + "\\My Excel Shortcut.lnk");
                oShellLink.TargetPath = "C:\\Program Files (x86)\\Microsoft Office\\Office14\\EXCEL.exe";
                oShellLink.WindowStyle = 1;
                oShellLink.Hotkey = "CTRL+SHIFT+E";
                oShellLink.IconLocation = "C:\\Program Files (x86)\\Microsoft Office\\Office14\\EXCEL.exe, 0";
                oShellLink.Description = "Shortcut for Excel";
                oShellLink.WorkingDirectory = "C:\\Program Files (x86)\\Microsoft Office\\Office14\\";
                oShellLink.Save();
                document.writeln("Shortcut for Excel Created Succesfully");
            }
        </script>
    </head>
    <body onload="javascript: createShortcut()">

    </body>
</html>

Note: This code only works in Internet Explorer.

No comments:

Post a Comment