Crating Executables

Need some Doper help here. I need to be able to create a simple Windows executable that will place on a user’s desktop an internet shortcut with a custom icon I created to an internal ordering catalogue for my company. This will be pushed out via a company and needs to be as simple as possible.

I already created the icon and know the target but I do not know how to create an executable. Is there a program out there that can help me or is this an involved procedure that involves coding? Any help will be greatly appreciated.

That should be Creating Executables.

To create an executable you will need to learn a programming language such as Visual Basic or C or C++ (or many others) and you will need to get a compiler.

An easier method will be to create a batch file.

Batch programs (also called batch files) allow you to simplify routine or repetitive tasks. A batch program is an unformatted text file that contains one or more commands and has a .bat or .cmd file name extension. When the file name is typed at the command prompt, the commands in the file are executed sequentially

and some commands are here

What alterego said, although I’m not sure batch files are smart enough to automatically figger out where the default desktop is. Is that a registry entry? Can batch files access the registry?

But besides that, I agree with alterego - making an executable to do something as basic as copying a file is overkill. Look into batch languages.

You need to know where the desktop is on the user’s system; in Win98, it’s C:\Windows\Desktop but in XP, it’s C:\Documents and Settings(username)\Desktop

If you want to do it the semi-manual way, you could create a text file (in Notepad), type in something like:


Save the file
Change the extension from .txt to .url
Email the file to your clients and ask them to drag/drop it on their desktops

In fact, this is likely to work better than emailing them an executable, because a lot of them will be stripping all executable attachments at the mail server, as a security/antivirus measure.

Mangetout, I was just going to send an e-mail with the link to the catalogue. I figured those who will use it often would be computer savvy enough to stick it in their favorites but then the boss got involved. Now he wants a custom icon of the project’s logo that the end user can click on. I’ve created the icon but can not figure out how to deliver it and that’s where the problem comes in.

Thanks for all the responses guys. I was hoping there was a simple way of doing this without having to have any coding knowledge but it doesn’t seem that way. I guess I’ll now have to travel to the underground lair of IT and hope I have appeased their Gods enough to be granted an audience with the head geek. I may have to sacrifice a virgin today.

Ah, bosses and expectations; I understand.

I would be inclined to point out to your boss that executable attachments will simply not remain attached in many cases - possibly even the majority - on the mail servers I’ve set up here, they are deleted carte blanche before the virus filter even looks at them.
In those remaining cases where the attachment does arrive intact, users may be wary of clicking on them (well, they should be wary). Virus guard programs that use heuristics may interpret your program’s attempt to copy a file as hostile and may block it anyway.

It’s widely considered bad practice to send executable attachments, even if your intentions are innocent.

Actually, re-reading the OP, you didn’t specify that it would be delivered by email, in which case just ignore my frenzied ranting.

The Desktop path can be gotten via “%USERPROFILE%\My Documents”

so, if you want an ultra-dodgy way of doing it:

create a new text file

open it up in notepad and type:

@echo off
cp <myshortcut> "%USERPROFILE%\My Documents\"

and rename it place_shortcut.bat

If I understand you, you don’t need an executable or a batch file. You only want to replace the standard explorer icon with your company logo. This is easy, assuming you have the logo saved in the correct format.

  1. Make an internet shortcut pointing to your homepage.

  2. Right click on the shortcut, select “properties.”

  3. Go to the “Web Document” tab.

  4. Select “change Icon” button.

  5. Browse to your icon file.

  6. Select your icon.

  7. Click on OK.

Also, if you want the shortcut to be available from the desktop no matter which user is logged on, you want to put it in the “\AllUsers\Desktop” folder rather than the “&lt;username>\Desktop” folder. However, I’m pretty sure you need admin priveleges to get to that folder.

Yeah, I did create the icon and changed the internet shorcut icon on my desktop the way Peter Morris described and that’s what actually started the problem. Once my boss saw what I had done he wanted that on everyone’s desktop in the company. But if I drag and drop the icon into my email it just sends the url and not the icon itself. I need a delivery format that will place the icon on the end users desktop once they click on the link in the email. I thought the simplest way would be a executable but I see that that may not be the way to go.

This needs to be put on over 500+ desktops and laptops all over the country. For as much as I would like to go around for the next few weeks doing it for everyone manually I don’t think that would be a good use of my time plus I don’t think my boss will approve my expnse report.

Probably the most elegant way to distribute it would be to do it from some clickable element on the web page itself (which could be an .exe file, although the user would be asked to confirm whether to run it).

I’m not aure how you’d implement it, but it certainly can be done; there’s a bit of software I use a lot (not sure if it’s available anymore) called huntersoft unknown Device Identifier - every time it runs, it plonks a shortcut on the desktop (annoying, but it is otherwise a useful bit of freeware) - I always run it now from a CD, but I have run it directly from the link on the web page 9actually, from my browser cache, I suppose) and it still puts the shortcut there.

You can create a shortcut and set its icon from a script, but you’ll need to copy the icon file from someplace. Can you have the script and the icon file sit on a file server, then have the script copy the icon file to the user’s computer when it creates the shortcut?

If that’s acceptable, put the following code in a text file and call it something.js (e.g. InstallShortcut.js). Copy the .js file and your .ico file to the server, then change the 4 variables at the top to have the relevant info in them. When you double-click the .js file, it will copy the icon to the user’s Program Files directory and create a shortcut in the All Users’ Desktop folder. Voila!

var shortcutURL = "";
var shortcutName = "Click Me";
var iconSourceDir = "\\\\myserver\\myshare\\location_of_my_icon"; //note: backslashes need to be doubled
var iconFileName = "myicon.ico";

    var shell = WScript.CreateObject("WScript.Shell");
        var fs = WScript.CreateObject("Scripting.FileSystemObject");
            var destfolder = shell.SpecialFolders("AllUsersDesktop");
            if(destfolder && destfolder != "")
                var icondest = null;
                var iconfolder = null;
                var env = shell.Environment("PROCESS");
                    iconfolder = env("ProgramFiles");

                if(!iconfolder || iconfolder == "")
                    WScript.Echo("Warning: Couldn't find program files folder.  Icon will not be created.");
                    icondest = iconfolder + "\\" + iconFileName;
                    var iconsrc = iconSourceDir + "\\" + iconFileName;
                    fs.CopyFile(iconsrc, icondest);
                var shortdest = destfolder + "\\" + shortcutName + ".lnk";
                var shortcut = shell.CreateShortcut(shortdest);
                    shortcut.TargetPath = shortcutURL;
                        shortcut.IconLocation = icondest + ", 0";
                    WScript.Echo("Error: Couldn't create shortcut (unknown reason)");
                WScript.Echo("Error: Couldn't find \"All Users\" desktop folder");
            WScript.Echo("Error creating filesystem object");
        WScript.Echo("Error creating shell object");
    WScript.Echo("Error: " + e.message);

Hope that helps.

You could make a .reg file, ans make the contents add a registry key, creating a desktop icon with particular characteristics.

Dunno what the contents would be like, but it’s just an idea.

I don’t follow. How do you create a desktop icon using the registry?