How Can I Create a Shortcut That Opens Internet Explorer With the Address Bar Hidden?

How Can I Create a Shortcut That Opens Internet Explorer With the Address Bar Hidden?

  • Comments 3
  • Likes
Hey, Scripting Guy! Question

Hey, Scripting Guy! How can I create a shortcut that opens Internet Explorer with the address bar hidden?

-- WA

SpacerHey, Scripting Guy! AnswerScript Center

Hey, WA. You know, any time a science fiction writer starts to run low on ideas he or she writes a story in which someone goes to bed and then wakes up in the morning to find that the world has completely changed overnight. Why? Because someone somewhere built a time machine, went back in time, and then did something that changed the future. (Yes, we know: time machines all include a warning sticker that tells people to avoid doing anything that might change the future. But nobody ever pays attention to those stickers.)

Something very similar seems to have happened here. When the Scripting Guy who writes this column went to bed last night, he knew that there was an easy and obvious answer to this question; in fact he was positive that there was an Internet Explorer startup switch that could be used for this very purpose. And yet, when he woke up this morning he discovered that there really wasn’t such a startup switch. Could he have been wrong? That’s a bit far-fetched, don’t you think? It’s far more likely that someone went back in time and removed the hide-the-address-bar startup switch from Internet Explorer. Disaster!

But have no fear; the Scripting Guys never allow some reckless time traveler to keep them from answering a question. Instead, we came up with a compromise solution, one that requires two items: a script, and a shortcut that calls that script.

Let’s start with the script:

Set objExplorer = CreateObject("InternetExplorer.Application")

strWebSite = Wscript.Arguments(0)

objExplorer.Navigate strWebSite   
objExplorer.AddressBar = 0
objExplorer.Visible = 1

As you can see, there’s not much to this. We start out by creating an instance of the InternetExplorer.Application object; as the name implies, that’s going to give us a running instance of Internet Explorer that we can call our own. We then use this line of code to take the first argument supplied to our script and store it in a variable named strWebSite:

strWebSite = Wscript.Arguments(0)

Where’s that argument going to come from? We’ll explain that in just a minute.

Next we use the following block of code to: 1) open the Web site stored in the variable strWebSite; 2) hide the address bar; and 3) make Internet Explorer visible on screen:

objExplorer.Navigate strWebSite   
objExplorer.AddressBar = 0
objExplorer.Visible = 1

Like we said, we couldn’t find a startup switch that would hide the address bar. However, if we programmatically start Internet Explorer we can hide the address bar simply by setting the AddressBar property to 0. So that’s what we did.

In case you’re interested, these lines of code hide the Internet Explorer toolbar and status bar, respectively:

objExplorer.ToolBar = 0
objExplorer.StatusBar = 0

All of that makes up the script called by our Internet Explorer shortcut. Now, let’s take a look at a second script, one that actually creates this shortcut:

Set objShell = CreateObject("Wscript.Shell")
strFolder = objShell.SpecialFolders.Item("Desktop")

Set objShortcut = objShell.CreateShortcut(strFolder & "\Open Web Site.lnk")
objShortcut.TargetPath = "c:\scripts\test.vbs"
objShortcut.Arguments = "http://www.microsoft.com/technet/scriptcenter"
objShortcut.Save

This is pretty simple little script, too. We start out by creating an instance of the Wscript.Shell object, the object used for creating shortcuts. Because we want this shortcut to appear on the desktop we then use this line of code to retrieve the path to the user’s desktop folder:

strFolder = objShell.SpecialFolders.Item("Desktop")

With us so far? Good. Our next step is to create the shortcut, something we do using the aptly-named CreateShortcut method:

Set objShortcut = objShell.CreateShortcut(strFolder & "\Open Web Site.lnk")

As you can see, all we need to do is pass CreateShortcut the file path for the new shortcut. Because we want this shortcut to appear on the desktop we create a path that combines the path to the desktop folder (a value stored in the variable strFolder), a \, and the shortcut file name: Open Web Site.lnk. In other words, we’re creating a shortcut with a path similar to this:

C:\Documents and Settings\Ken Myer\Desktop\Open Web Site.lnk

Next we need to assign values to two properties: TargetPath and Arguments. The TargetPath is the script we want to call whenever we use the shortcut; in this case that’s the script C:\Scripts\Test.vbs. The Arguments property, meanwhile, represents any command-line arguments that we want to pass to the script. Because we want this shortcut to open a link to the Script Center (http://www.microsoft.com/technet/scriptcenter) we assign the Script Center URL to the Arguments property.

Finally, we call the Save method to officially save our new shortcut to the file system.

Now for the exciting part: what’s going to happen when we use this shortcut? Well, the shortcut will call C:\Scripts\Test.vbs, passing the Script Center URL as the first (and only) command-line argument. Test.vbs will:

1.

Create an instance of Internet Explorer.

2.

Use the Navigate method to open the Script Center URL.

3.

Hide the address bar.

4.

Appear on screen.

Give it a try and see for yourself.

Or, alternatively, get a time machine, go back and time, and make sure that a startup switch that enables you to hide the address bar is added to Internet Explorer. Whichever way is easier for you is fine by us.

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment
  • Hi,

    am looking for a solution that can create a shortcut to an application that we use.

    It is possible to use in an HTA script with multiple options that have shortcuts like this:

    x: \ app \ app01.bat -> Shortcut -> APP 01

    x: \ app \ app02.bat -> Shortcut -> APP 02

    x: \ app \ app03.bat -> Shortcut -> APP 03

  • It's too complicated. Keep it simple by attaching a script file and the shortcut file and ask people to modify the params as required.! :) Cheers

  • Hi,
    Is anyway to hide the IE toolbar, statusbar if I use Wshshell code to launch IE?

    Example: vbscript
    Set objExplorer = CreateObject("InternetExplorer.Application")
    objExplorer.Navigate "http://technet.com"
    objExplorer.ToolBar = 0
    objExplorer.StatusBar = 0
    objExplorer.Visible = 1

    I need to replace first 2 lines with
    Set WshShell = WScript.CreateObject("WScript.Shell")
    Return = WshShell.Run("iexplore.exe http://technet.com",1)

    Thanks,