Page 1 of 2

Opening web page using dos

Posted: 27 Sep 2012 05:10
by Raje
Hi ,

I am very new to dos programming . At specific time , I want to open three specific web pages using scheduler task in windows. Here is the program which is working correctly on double click of batch file , but when it is called by scheduler , it opens only "http://www.dostips.com" page. Can anyone please tell me what i have missed here.

@echo off
SET /P ANSWER=Do u wanna continue (Y/N)?
if /i {%ANSWER%}=={y} (goto :yes)
if /i {%ANSWER%}=={yes} (goto :yes)
goto :no
:yes
start /m -new iexplore url2
start /d iexplore url1
start /d iexplore http://www.dostips.com/
exit /b 0

Thanks
Raje

Re: Opening web page using dos

Posted: 27 Sep 2012 05:17
by abc0502
try this, it should work

Code: Select all

@echo off 
SET /P ANSWER=Do u wanna continue (Y/N)?
if /i {%ANSWER%}=={y} (goto :yes)
if /i {%ANSWER%}=={yes} (goto :yes)
goto :no
:yes
start "" "URL_1"
start "" "URL_2"
start "" "URL_3"
exit /b

replace "URL_x" with your url

Re: Opening web page using dos

Posted: 27 Sep 2012 05:24
by Raje
Hi ,

I tried the same , but still it is opening only the 3rd url and the first and second .

Re: Opening web page using dos

Posted: 27 Sep 2012 05:44
by abc0502
I tried the same , but still it is opening only the 3rd url and the first and second .

ok, then what is the problem

Re: Opening web page using dos

Posted: 27 Sep 2012 05:49
by Raje
i think the problem is three web pages are opening in same page . So , Initially url1 opens then it gets overwrite by url2 and then by third link. Can it is possible to say open in different tabs?

Re: Opening web page using dos

Posted: 27 Sep 2012 06:01
by abc0502
so you want all three url open in One window but different tabs
if so, just give me some time :)

Re: Opening web page using dos

Posted: 27 Sep 2012 06:31
by abc0502
According to the 3rd answer here:
For me it worked as below:

Code: Select all

@echo off
start /d "" IEXPLORE.EXE www.google.com
start /d "" IEXPLORE.EXE www.yahoo.com

With the settings in Internet Explorer 8:
always open popups in a new tab
a new tab in the current window


so modify the Internet explorer settings,
from tools - internet settings in general tab find tabs and select settings
then in when a pop-up is encountered select Always open pop-up in anew tab

and for firefox you can see This

Re: Opening web page using dos

Posted: 27 Sep 2012 06:44
by Raje
I am using IE 8 with same options enabled . But still the links are opens in separate windows.

Re: Opening web page using dos

Posted: 27 Sep 2012 07:03
by foxidrive
IE 9 doesn't open them in tabs either. I fiddled with the tab settings but nothing changed the behaviour of opening in two windows.

Re: Opening web page using dos

Posted: 27 Sep 2012 07:27
by foxidrive
This works here:

Code: Select all

@echo off
set file="%temp%\openIE.vbs"
 >%file% echo on error resume next
>>%file% echo navOpenInBackgroundTab = ^&h1000
>>%file% echo set oIE = CreateObject("InternetExplorer.Application")
>>%file% echo Set args = WScript.Arguments
>>%file% echo oIE.Navigate2 args.Item(0)
>>%file% echo for inx = 1 to args.count
>>%file% echo oIE.Navigate2 args.Item(inx),navOpenInBackgroundTab
>>%file% echo next
>>%file% echo oIE.Visible = true


cscript /nologo %file% www.google.com www.yahoo.com

del %file% 2>nul

Re: Opening web page using dos

Posted: 27 Sep 2012 08:48
by Squashman
The -new switch is for new instance of IE not a new tab.
So this will open up two instances of IE.
start iexplore.exe -new http://yahoo.com
start iexplore.exe -new http://google.com

Re: Opening web page using dos

Posted: 27 Sep 2012 10:59
by abc0502
@Foxidrive
Your batch work perfect, and if it could wait a few seconds before opening the next website, it will prevent any hanging

Re: Opening web page using dos

Posted: 27 Sep 2012 22:28
by foxidrive
This includes a 3 second delay between pages.

Code: Select all

@echo off
set file="%temp%\openIE.vbs"
 >%file% echo on error resume next
>>%file% echo navOpenInBackgroundTab = ^&h1000
>>%file% echo set oIE = CreateObject("InternetExplorer.Application")
>>%file% echo Set args = WScript.Arguments
>>%file% echo oIE.Navigate2 args.Item(0)
>>%file% echo for inx = 1 to args.count
>>%file% echo oIE.Navigate2 args.Item(inx),navOpenInBackgroundTab
>>%file% echo WScript.Sleep 3000 ' The 3000 = 3 seconds
>>%file% echo next
>>%file% echo oIE.Visible = true


cscript /nologo %file% www.google.com www.yahoo.com

del %file% 2>nul

Re: Opening web page using dos

Posted: 28 Sep 2012 02:31
by abc0502
@Foxidrive,
Perfect ,thanks :)

Re: Opening web page using dos

Posted: 28 Sep 2012 10:40
by Dos_Probie
You did not say what OS you were using but here's how I do it with Windows 7 and using Firefox..
Run Schtasks first from batch to setup, my example runs daily with start date and set to military time.
Then put your batch in root of c: drive, my example is Web.Pages.cmd.
That't it.. :mrgreen:

Code: Select all

@echo off
::Schtask.cmd
schtasks /create /tn "My.Web.Pages" /tr "\"c:\Web.Pages.cmd\" arguments" /sc daily /sd 09/29/2012 /st 16:30
echo.
echo * DONE *
pause
exit


Code: Select all

@echo off
::Web.Pages.cmd
SETLOCAL ENABLEEXTENSIONS


::Variables
set browser=firefox.exe
set wait_time=2

:: 1. Open multiple tabs for firefox.
START %browser% -new-tab "mail.yahoo.com"
@ping 127.0.0.1 -n %WAIT_TIME% -w 1000 > nul
start "" %browser% -new-tab "support.microsoft.com/fixit/en-us"
start "" %browser% -new-tab "visualbasicscript.com"
start "" %browser% -new-tab "giveawayoftheday.com"
start "" %browser% -new-tab "dostips.com"

:: 2. Permanently set Urls in user profile for firefox.
pushd "%userprofile%\Application Data\Mozilla\Firefox\Profiles"
for /f "delims=" %%a in ('dir /b /ad') do (
echo user_pref^("browser.startup.homepage", "http://www.google.com/|http://www.bing.com/|http://www.dostips.com"^);>>"%%a\user.js"
)
popd

:: 3. Another Way
start "" firefox.exe www.google.com www.bing.com www.dostips.com

exit