Question

I want to create a batch file which creates a shortcut on the desktop or in the start menu.

The shortcut needs to open a webpage which is a local windows server ip address(like 'http:\192.168..*:81\').

I also want to provide a custom image icon to the shortcut.

Was it helpful?

Solution

I know this is an old thread but it was the first StackOverFlow page to popup in Google, so I thought I'd make a reply.

The following is a batch script that I use to manage URL shortcuts: (please note that this script assumes that an icon also exists - MyIconName.ico - in the same directory as this script. If an icon is not available or not required, simply omit the pertinent lines)

Please note also that any trailing spaces will affect the value of the variable...

@echo off 
@echo. 
@echo.
@echo.

::Set the application-specific string vars 
SET AppDescription=MyAppName
SET IconName=MyIconName.ico
SET Shortcut_Name=MyShortcutName.url
SET URL_PATH=http://www.Google.com

::Set the common string vars 
SET WORKING_PATH=%~dp0
SET ICONDEST=c:\ProgramData\%AppDescription%
SET LinkPath=%userprofile%\Desktop\%Shortcut_Name%

@echo. Copy Icon 
IF EXIST "%ICONDEST%" (GOTO _CopyIcon) 
mkdir "%ICONDEST%"
:_CopyIcon 
copy "%WORKING_PATH%%IconName%" "%ICONDEST%"

echo. 
echo. Create desktop shortcut... 
echo [InternetShortcut] > "%LinkPath%"
echo URL=%URL_PATH% >> "%LinkPath%"
echo IDList= >> "%LinkPath%"
echo IconFile=%ICONDEST%\%IconName% >> "%LinkPath%"
echo IconIndex=0 >> "%LinkPath%"
echo HotKey=0 >> "%LinkPath%"
echo. 
echo. 
echo. 
echo. 
echo.You should now have a shortcut to %AppDescription% on your desktop... 
echo. 
echo. 
pause 

OTHER TIPS

If it weren't for the custom image icon requirement, I'd suggest using the following to create a batch file on the desktop like this:

echo start http://192.168.1.1:81 > "%userprofile%\desktop\Launch website.cmd"

Naturally, replace the address with the appropriate one. This doesn't create a shortcut (actually creates a file), and it won't give you a custom icon, but it's an easy way to accomplish the functionality you seem to be looking for.

Your description doesn't give enough information about the problem you're trying to solve, but if it really is simply what you say, you could also just create the shortcut once, by hand, and then use a batch file to copy that shortcut to wherever you wanted it.

Please add more detail to your question if we're missing the boat here...

if you use Mozilla Firefox

start /MIN /d"C:\Program Files\Mozilla Firefox" firefox.exe http://www.yourlink.com

if you use Google Chrome

start /MIN /d"C:\Program Files\Google Chrome" chrome.exe http://www.yourlink.com

There is no way you can do with just batch file/windows shell commands. There are two options:

  1. Use a VBScript as described here
  2. Use third-party tools

I haven't tested it, but the link below seems to have a script in batch, yes batch, that creates shortcuts!

http://www.robvanderwoude.com/amb_shortcuts.php

suppose you want to add a shortcut for www.google.com you can try this one

echo [InternetShortcut] >"%userprofile%\desktop\google.url"
echo URL=http://www.google.com/ >>"%userprofile%\desktop\google.url"
echo IconFile=e:\icons\google.ico  >>"%userprofile%\desktop\google.url"
echo IconIndex=0 >>"%userprofile%\desktop\google.url"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top