Computing.Net > Forums > Programming > MS Dos batch Script Help

MS Dos batch Script Help

Reply to Message Icon

Original Message
Name: David06
Date: July 30, 2006 at 16:33:48 Pacific
Subject: MS Dos batch Script Help
OS: Windows 2000
CPU/Ram: 512 mb
Model/Manufacturer: Toshiba Tecra
Comment:

Hi,
I need a help in MS DOS batch script. Can I call an Internet session in a batch mode in DOS script? Following example explains my problem.

@echo off

iexplore www.mytestphp.com^&myparam.php

rem Above command successfully opens an rem internet browser with my required rem path name But I need control to pass rem back to the batch script

type mydata.txt >mytest2.txt

goto End

:End



Report Offensive Message For Removal


Response Number 1
Name: Mechanix2Go
Date: July 30, 2006 at 20:23:58 Pacific
Subject: MS Dos batch Script Help
Reply: (edit)

::== some.bat
start www.Golden-Triangle.com
type mydata.txt > mytest2.txt
:: DONE


=====================================
If at first you don't succeed, you're about average.

M2



Report Offensive Follow Up For Removal

Response Number 2
Name: David06
Date: July 30, 2006 at 21:06:18 Pacific
Subject: MS Dos batch Script Help
Reply: (edit)

Thanks a lot that is working. One more quick question how do I kill a IE browser session from the batch script.

::== some.bat
start www.Golden-Triangle.com
type mydata.txt > mytest2.txt

kill browser session for www.Golder-Traingle.com

exit
:: DONE



Report Offensive Follow Up For Removal

Response Number 3
Name: Mechanix2Go
Date: July 30, 2006 at 21:21:35 Pacific
Subject: MS Dos batch Script Help
Reply: (edit)

No idea.


=====================================
If at first you don't succeed, you're about average.

M2



Report Offensive Follow Up For Removal

Response Number 4
Name: David06
Date: July 31, 2006 at 00:18:20 Pacific
Subject: MS Dos batch Script Help
Reply: (edit)

Further testing reveals that start command only recognize web address starting with 'www'. My intended web address does not start with 'www'. Please help!


Report Offensive Follow Up For Removal

Response Number 5
Name: Mechanix2Go
Date: July 31, 2006 at 00:36:36 Pacific
Subject: MS Dos batch Script Help
Reply: (edit)

You could make a URL:

[InternetShortcut]
URL=http://www.golden-triangle.com/


Then:

start GT.URL


=====================================
If at first you don't succeed, you're about average.

M2



Report Offensive Follow Up For Removal


Response Number 6
Name: Shr0Om
Date: July 31, 2006 at 00:50:58 Pacific
Subject: MS Dos batch Script Help
Reply: (edit)

Ive been experimenting a little bit with your request, but unfortunately it has two major drawbacks..

1. The window you want to kill has to be the active window.

2. If you run the batch from windows, it will become the active windows. If you are in console and run the script, it works for some reason (windows doesnt see it as an active window).

I dont have time to experiment with it more right now, but perhaps anyone else have time to improve the script?

::---CODE---
@echo off
SetLocal EnableDelayedExpansion
::Find PID of process which contains windowtitle "Google"

Tasklist /FI "WINDOWTITLE eq Google - Microsoft Internet Explorer" /FO "CSV" >>tmp


::Filtering out PID of the process list

For /F "tokens=1-5* delims=," %%A in (tmp) Do (
set Txt=%%B
Echo !Txt:^"=!>>tmp1)
)

::Getting PID to kill
set /p PID=<tmp1


::Killing process
Taskkill /PID %PID%

::Delete tmp files
del tmp
del tmp1
EndLocal

::---CODE---


Report Offensive Follow Up For Removal

Response Number 7
Name: Mechanix2Go
Date: July 31, 2006 at 01:02:05 Pacific
Subject: MS Dos batch Script Help
Reply: (edit)

Hi Scroom,

No tasklist or taskkill in my w2000.

LOL


=====================================
If at first you don't succeed, you're about average.

M2



Report Offensive Follow Up For Removal

Response Number 8
Name: Shr0Om
Date: July 31, 2006 at 01:55:30 Pacific
Subject: MS Dos batch Script Help
Reply: (edit)

Hehh, sorry. Seems to be a Xp Pro tool only. But there are alternatives.

http://www.windowsnetworking.com/kbase/WindowsTips/WindowsXP/AdminTips/Utilities/TlisttasklistPUlistlistsactivetasksandprocesses.html


Report Offensive Follow Up For Removal

Response Number 9
Name: ghostdog
Date: July 31, 2006 at 03:07:07 Pacific
Subject: MS Dos batch Script Help
Reply: (edit)

I suppose you want to grab some web pages to your local ?.. Though batch can be done, but i like it simpler using Python... :-)

>>> import urllib2
>>> retrieved = urllib2.urlopen("http://www.somesite.com")
>>> all = retrieved.read()
>>> open("retrieved.html","w").write(all)

There is no need to open the web page using your browser or kill your browser's process.
NB:similarly can be done in Perl/Vbscript...



Report Offensive Follow Up For Removal

Response Number 10
Name: Mechanix2Go
Date: July 31, 2006 at 03:48:47 Pacific
Subject: MS Dos batch Script Help
Reply: (edit)

Hi ghostdog,

Yeah, if you just want to get a page you could use WGET or any of several scripting lamgs. No tellin' where we're going with this.

Hi Shroom,

I looked at that link but didn't see any way to get the utilities.


=====================================
If at first you don't succeed, you're about average.

M2



Report Offensive Follow Up For Removal

Response Number 11
Name: Shr0Om
Date: July 31, 2006 at 04:12:32 Pacific
Subject: MS Dos batch Script Help
Reply: (edit)

M2:

Well, i guess it should be possible to download the NT4 resourcekit (says it works in wk2 aswell) containing those tools from microsoft?

But my script wasn't really doing the job very well anyway.
I could use taskkill "IEXPLORER" but that would just close all IE's windows, and not just the goldentriangle window.

Perhaps another programming language would be the solution.


Report Offensive Follow Up For Removal

Response Number 12
Name: ghostdog
Date: July 31, 2006 at 04:57:48 Pacific
Subject: MS Dos batch Script Help
Reply: (edit)

There are also pslist, pskill from sysinternals which can be used to list/kill processes.


Report Offensive Follow Up For Removal

Response Number 13
Name: uli_glueck
Date: July 31, 2006 at 05:38:34 Pacific
Subject: MS Dos batch Script Help
Reply: (edit)

M2

you can download the [RK]commands for W2k from the Microsoft Website.
The complete [RK] isn`t free.

uli


Report Offensive Follow Up For Removal

Response Number 14
Name: David06
Date: August 2, 2006 at 18:07:12 Pacific
Subject: MS Dos batch Script Help
Reply: (edit)

I havent tried any of the options mentioned here as the client requirement has changed. But thanks a lot for your help.


Report Offensive Follow Up For Removal

Response Number 15
Name: Mechanix2Go
Date: August 2, 2006 at 23:29:54 Pacific
Subject: MS Dos batch Script Help
Reply: (edit)

Thanks, uli

David06, let us knowe how it plays out.


=====================================
If at first you don't succeed, you're about average.

M2



Report Offensive Follow Up For Removal






Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: MS Dos batch Script Help

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




How often do you use Computing.Net?

Every Day
Once a Week
Once a Month
This Is My First Time!


View Results

Poll Finishes In 3 Days.
Discuss in The Lounge