Reputation: 1162
I am new to this and I am trying a basic example I saw on Youtube:
@echo off
echo this little program helps you to refresh a website
pause
cls
echo but first we have to do some preferences
pause
cls
echo please enter the website name here
set /p website=
cls
echo please enter the time between refreshes
set /p time=
cls
echo Set limited or unlimited refresh
set /p refresh=
if'%refresh%'=='1' goto :once
if'%refresh%'=='0' goto :unlimited
cls
:once
cls
echo Preferences finished
pause
timeout /t %time% /nobreak
start %website%
exit
:unlimited
cls
echo Preferences finished
pause
:again
timeout /t %time% /nobreak
start %website%
goto :again
This code is supposed to ask a user for a website and a refresh time and it will refresh that website by reopening it in IE (Internet Explorer), however I have 2 problems with this:
Upvotes: 0
Views: 127
Reputation:
There are some syntax errors in your script.
EXIT
commandEXIT
exits the script. You may want to change that to something else.
IF
Statementif'%refresh%'=='1' goto :once
is slightly incorrect, as there is a missing space between if
and the comparee. In addition, using double quotes ensure it to successfully compare with values including spaces.
if "%refresh%"=="1" goto :once
If variable %refresh%
is not 1 or 0, it goes to :once
and execute the code there.
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.AppActivate("Chrome")
WshShell.SendKeys "{F5}"
Save this script as Refresh.vbs
and put it in the same folder as the batch file.
Then, when you want to refresh the webpage, do cscript //nologo Refresh.vbs
.
Upvotes: 1