Computer Hope

Microsoft => Microsoft DOS => Topic started by: Narsil on September 04, 2007, 09:47:56 AM

Title: [solved] HTTP request from DOS batch, is this possible ?
Post by: Narsil on September 04, 2007, 09:47:56 AM
Hi,

I need some help with a very simple batch file that needs to be launched automatically at each start of a Win XP machine.

I need to send an http request to a .php URL to initiate a connection at each boot from a PC. I was wondering if a DOS batch could do that.

Any suggestion ?

Thanks,
Diego
Title: Re: HTTP request from DOS batch, is this possible ?
Post by: Narsil on September 04, 2007, 09:51:42 AM
PS: Even better if a POST data could be added to the request ...
Title: Re: HTTP request from DOS batch, is this possible ?
Post by: Amrykid on September 04, 2007, 04:55:13 PM
this is a tough one.
requires to things, batch and vbscipt
Batch:
Code: [Select]
start http.vbsVbscipt:
Code: [Select]
httprequest("urlhere")any body else help me if im wrong.
Title: Re: HTTP request from DOS batch, is this possible ?
Post by: Narsil on September 04, 2007, 11:56:24 PM
Thanks Amrykid,

Stupid question : what do i need to install run a vb script ?
Title: Re: HTTP request from DOS batch, is this possible ?
Post by: ghostdog74 on September 05, 2007, 01:51:51 AM
see here (http://www.computerhope.com/forum/index.php/topic,40496.0.html).
Title: Re: HTTP request from DOS batch, is this possible ?
Post by: Amrykid on September 05, 2007, 05:11:53 PM
you dont need to install anything to run a VB script ;D. just save that code to http.vbs through notepad ;D
Title: Re: HTTP request from DOS batch, is this possible ?
Post by: gamerx365 on September 05, 2007, 05:20:48 PM
im just curious why you would need to do this. Not suspicious of anything, i just am always trying to see what kind of new things I can do with this kind of stuff. so what exactly would this do and why would you need it?
Title: Re: HTTP request from DOS batch, is this possible ?
Post by: Narsil on September 06, 2007, 12:37:57 AM
No prob'

To remote access my clients machines, who are mostly cable/adsl connected, thus have dynamic IP, i need to know their IP. To do this, I have on my web site a small php script that logs the incoming request's IP in a table this way :

http://mysite.com/iplog/iplog.php/?ident=client1  ->  [20070906 08:17] client1 xxx.xxx.xxx.xxx

When needed, I used to ask to my clients to call this URL (saved as bookmark) and picked the IP from the table.

I though I could give better service and do some night maintenance if I could know the IP without their help ...

You can complete by yourself  ;)

For my "other world"'s client (linux and Mac), i have the very convenient "curl" command witch can be shell scripted and croned easily, but as my Win world's knowledge are ... lacked, I needed help !

Thanks a lot !

Diego
Title: Re: HTTP request from DOS batch, is this possible ?
Post by: ghostdog74 on September 06, 2007, 01:55:08 AM
one way in vbscript
Code: [Select]
set http = CreateObject("microsoft.xmlhttp")
http.open "GET","http://127.0.0.1",false
http.send
htmlpage = http.responsetext
WScript.Echo htmlpage
i leave it to you to get the client IP address...ie..you have to learn some vbscript.
another way is to use netcat...search for netcat (http://www.vulnwatch.org/netcat/) for windows...
eg
Code: [Select]
echo "GET / HTTP/1.0

" | nc yoururl 80
OR, you can use Windows Curl...search the web for "Curl for windows"
Title: Re: HTTP request from DOS batch, is this possible ?
Post by: Narsil on September 06, 2007, 02:27:20 AM
OR, you can use Windows Curl...search the web for "Curl for windows"

Oh oh ! This one's good !

Keep It Simple  8)
Title: Re: HTTP request from DOS batch, is this possible ?
Post by: mariah on September 07, 2007, 06:53:28 AM
example:

@echo off
"C:\Program Files\Internet Explorer\IEXPLORE.EXE" "http://hotmail.com"
cls
exit

is this what you needed?
Title: Re: [solved] HTTP request from DOS batch, is this possible ?
Post by: Narsil on September 07, 2007, 07:01:05 AM
Thanks mariah.

Your solution's good too

I've choose to install curl for windows. it's light, easy, and i know it !

Thanks to all of you for your suggestions.

Diego