0Day Forums
How to create a batch file to create a shortcut to a webpage - Printable Version

+- 0Day Forums (https://0day.red)
+-- Forum: Coding (https://0day.red/Forum-Coding)
+--- Forum: .bat & .wsf & .cmd (https://0day.red/Forum-bat-wsf-cmd)
+--- Thread: How to create a batch file to create a shortcut to a webpage (/Thread-How-to-create-a-batch-file-to-create-a-shortcut-to-a-webpage)



How to create a batch file to create a shortcut to a webpage - studhorse383 - 07-23-2023

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.




RE: How to create a batch file to create a shortcut to a webpage - sunnypmrgmj - 07-23-2023

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][1]
2. Use third-party tools


[1]:

[To see links please register here]




RE: How to create a batch file to create a shortcut to a webpage - saddlecloth388 - 07-23-2023

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

[To see links please register here]




RE: How to create a batch file to create a shortcut to a webpage - turin20677 - 07-23-2023

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

[To see links please register here]

> "%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...


RE: How to create a batch file to create a shortcut to a webpage - Pronayavxr - 07-23-2023

if you use Mozilla Firefox

> start /MIN /d"C:\Program Files\Mozilla Firefox" firefox.exe
>

[To see links please register here]


if you use Google Chrome

> start /MIN /d"C:\Program Files\Google Chrome" chrome.exe
>

[To see links please register here]




RE: How to create a batch file to create a shortcut to a webpage - duelingjgtvtqtrg - 07-23-2023

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


RE: How to create a batch file to create a shortcut to a webpage - bsekcdbgrq - 07-23-2023

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"
```