user1475128
user1475128

Reputation: 35

Use a batch file to open a .HTML file in a web broswer with URL parameter

Is it possible to open a local HTML file in a web browser with parameters. The following is my script:

 SETLOCAL ENABLEDELAYEDEXPANSION

:: Set the First Parameter - image directory - to a local variable for processing
SET imageDir=%1

:: Remove the double quotes from the image directory 
SET imageDir=%~1

:: Replace any spaces with %20 
set imageDir=!imageDir: =%%20!

:: Append image directory to the URL and launch
START file:///C:/Folder/demo.html?param=!imageDir!

The file currently opens, without the "param".

Many Thanks

Upvotes: 2

Views: 1009

Answers (1)

Rafael
Rafael

Reputation: 3112

This was the best I could think:

@echo off
SETLOCAL ENABLEDELAYEDEXPANSION
SET imageDir=%1
SET imageDir=%~1
set imageDir=!imageDir: =%%20!
echo/^<meta http-equiv="refresh" content="0; url=file:///C:/Folder/demo.html\?param=!imagedir!" /^>>_temp.html
_temp.html&del _temp.html

Upvotes: 1

Related Questions