Windows IT Pro is the leading independent community for IT professionals deploying Microsoft Windows server and client applications and technologies.
  
  
  Advanced Search 


October 09, 2006

Using URLs in Batch Files


RSS
View this exclusive article with VIP access -- click here to join |
See More Batch Files Articles Here | Reprints | Or sign up for our VIP Monthly Pass!

Batch files provide advantages over using desktop shortcuts or browser favorites to connect to frequently used Web sites. You can launch sites without needing to hunt down the page in your favorites list and even use command-line arguments to retrieve specific content much more quickly. If you put the batch files in a common tools directory on the network, you can access them from any machine, even if you're logged on as another user. However, the command shell's treatment of certain common URL characters, such as the percent sign (%), can make batch files containing URLs fail, even though the commands you use will work fine if you type or paste them at a command prompt. When you understand why this problem occurs, you can work around it, and I'll show you how by using a couple of Google and Microsoft Knowledge Base lookups as examples.

Performing a Google Phrase Search
The situations in which I usually see this problem involve extremely long Internet URLs, frequently for reference pages in online specialty sites; however, the problems are the same as you'd encounter with a simple Google phrase search. For example, if you look up the phrase parent process on Google, the URL at the top of the results page will be http://www.google.com/search?q=%22parent+process%22. The Windows command shell can't understand commands that begin with protocol handlers such as "http://", but if you invoke the URL with cmd.exe's Start command, the URL will automatically be passed to the default Web browser. For example, entering the following text at a command prompt

Start http://www.google.com/
 search?q=%22parent+
 process%22 

opens your Web browser and passes the page request to Google. (Although this command appears on several lines here, you would enter it on one line in the command-shell window. The same holds true for the other multiline commands in this article.) So far, so good. . . .


Already a VIP member?
Please log on to view the full article

Why become a VIP member?

VIP-only online access
VIP CD delivered twice a year: offline access to the entire Windows IT Pro article library
Monthly issue of your choice of Windows IT Pro or SQL Server Magazine

Subscribe Now
Top Viewed ArticlesView all articles
Command Prompt Tricks

One reader shares his tip for setting up the command prompt to reflect a remote path. ...

WinInfo Short Takes: Week of November 9, 2009

An often irreverent look at some of the week's other news, including some more Windows 7 sales momentum, some Sophos stupidity, Microsoft's cloud computing self-loathing, more whining from the browser makers, Zoho's "Fake Office," and much, much more ...

Understanding File-Size Limits on NTFS and FAT

A general confusion about files sizes on FAT seems to stem from FAT32's file-size limit of 4GB and partition-size limit of 2TB. ...


Scripting Whitepapers From Development to Production: Streamlining SharePoint Deployment with DocAve Deployment Manager

Related Events Check out our list of Free Email Newsletters!

Scripting eBooks Keeping Your Business Safe from Attack: Encryption and Certificate Services

Best Practices for Managing Linux and UNIX Servers

Building an Effective Reporting System

Related Scripting Resources Become a VIP member of the Windows IT Pro community!
Get it all with the VIP CD and VIP access. A $500+ value for only $279!

Subscribe to Windows IT Pro!
Solve your toughest technical problems with our experts and access 10,000 + articles online. 30% off

Monthly Online Pass - Only $5.95!
Get instant access to 10,000+ articles from Windows IT Pro Magazine!


Windows IT Pro Home Register FAQ for Windows WinInfo News
Europe Edition About Us Contact Us/Customer Service Media Kit Affiliates / Licensing  
SQL Server Magazine Office & SharePoint Pro DevProConnections IT Job Hound
Left-Brain.com Technology Resource Directory asp.netPRO ITTV Windows SuperSite 
 
 Windows IT Pro is a Division of Penton Media Inc.
 © 2009 Penton Media, Inc. Terms of Use | Privacy Statement