B
B
batalek2021-02-10 11:12:04
cmd/bat
batalek, 2021-02-10 11:12:04

How to force .bat file to create .html file and open it?

How can I have my run.bat create a {Random 5 letter}.html file and open it on the screen?
Like I click on the batch file, it immediately creates the {Random set of 5 letters}.html file, it will turn out like 6fe6c.html and the batch file will immediately open it as the user opens it on his own, but this time the batch file itself should create and open the file automatically on the screen.

@echo off
set OUTPUT=www.html

if "%STDOUT_REDIRECTED%" == "" (
    set STDOUT_REDIRECTED=yes
    cmd.exe /c %0 %* >%OUTPUT%
    exit /b %ERRORLEVEL%
)

echo ^<html^>
echo ^<head^>
echo ^<title^>This is a greeting page^</title^>
echo ^</head^>
echo ^<body^>
echo Hello World!
echo ^</body^>
echo ^</html^>
echo ^<!== Its your page :D ==>^>www.html
more www.html

used this code, it creates a file with only the name www, and it’s beneficial for me that it creates a file with {A random set of 5 letters should turn out like 7fhsc.html}.html but it doesn’t open, it just creates it appears on the screen and everything is fine, but I need so that it immediately opens this file after creation.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2021-02-10
@NeiroNx

5 letters is a difficult task in cmd, I would just take numbers:

set OUTPUT=%RANDOM%%RANDOM%.html
...
start %OUTPUT%

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question