Search code examples
internet-exploreractivexjscript

is it possible to minimize to desktop, and select a certain icon on the desktop using Internet explorer jscript activex?


I am working in a windows domain intranet where I would like to make a fool proof way to add a shortcut to a file, using code from a webpage to the desktop and make it visible to the user, assuming the whole intranet has internet explorers which are configured the same which allows any jscript activex code. I need to achieve the next tasks, some of them are already achieved:

1.Create a shortcut to an exe application on the desktop (Achieved)

function createDesktopShortcut(targetFile){
    var shell = new ActiveXObject("WScript.Shell"),
        shortcut = shell.CreateShortcut("C:\\Users\\someuser\\Desktop\myshortcut.ico"),
        fso = new ActiveXObject("Scripting.FileSystemObject"),
    shortcut.TargetPath = fso.BuildPath(windir,targetFile);
    shortcut.Save();
}

2.Minimize the Internet explorer window (Undone): problems: What if there are other windows behind? how to minimize them all similar to the Show the desktop functionality?

function Minimize()
{
window.innerWidth = 100;
window.innerHeight = 100;
window.screenX = screen.width;
window.screenY = screen.height;
alwaysLowered = true;
}

3.Select the new shortcut that has just been added to make the User notice where its(Unknown): need a solution

to conclude: maybe my understanding of activex is wrong and it has far less control of the system than I imagine however please let me know if the task is too far fetched and optimizations to the code are very welcome thanks alot!


Solution

  • I don't know, if selecting an icon programmatically is even possible, but you can show the desktop like so:

    new ActiveXObject('Shell.Application').toggleDesktop();