2

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

1
  • file:// references the file protocol. It is not possible with this protocol to add optional parameters which are processed usually on server side like ?param=.... You need a locally installed webserver and use http://localhost/. Commented Oct 22, 2014 at 14:55

1 Answer 1

1

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.