Someone want to help me?

Post here about scripting and programming for HaloPC (audio, network, ai, etc.)
Post Reply
Jdogg





Posts: 184
Joined: Thu Aug 31, 2006 3:18 pm

Someone want to help me?

Post by Jdogg »

I need to know if it is possible to make a bacth file that will save its screen as a log..

for example.

@echo off
ipconfig
pause.

this is what it does..

Image

So as you can see, can i save all that into a text file or something???

thanks all
User avatar
Tural




Conceptionist Acolyte Bloodhound Recreator
Socialist Connoisseur Droplet Scorched Earth
Grunge

Posts: 15628
Joined: Thu Jun 16, 2005 3:44 pm
Location: Lincoln, NE
Contact:

Post by Tural »

You know, your local IP is useless to anyone not on your network, there's no reason to even block it out...

On top of that, it clearly says 192.168.1.55 =x
User avatar
[cc]z@nd!




Literarian 500

Posts: 2297
Joined: Tue May 04, 2004 1:52 pm
Location: michigan

Post by [cc]z@nd! »

i have a program on my jump drive to do exactly this. here's the code, and an explanation of how it works (so it doesn't feel like i'm doing your homework for you)

Code: Select all

@echo off
time /t>ipconfig\%computername%.txt 
echo ------------------------------------------->>ipconfig\%computername%.txt      
echo.>>ipconfig\%computername%.txt
echo.>>ipconfig\%computername%.txt
echo.>>ipconfig\%computername%.txt
echo.>>ipconfig\%computername%.txt
ipconfig /all>>ipconfig\%computername%.txt

the explanation:

@echo off = basically, so we only see the output. considered standard for finished batch files.
the time /t command displays the time, and i use a pipe (>) to store the output in a file, so time /t>ipconfig\%computername%.txt will take the output of the time /t command, and store it in the %computername% text file in the ipconfig folder, either creating the file if it doesn't exist, or overwriting it if it does.

for this to work as written, the directory structure must be kept the same, so if this batch file is in a folder called "batch", then there must be a folder called "ipconfig" in the "batch" folder. then, after you run this code on a few different computers, you'll see it get populated by some different text files.

the echo. command gives a blank line because of the period directly at the end of the echo command. i then use a pipe to put it in the same file the time was put in, but you'll notice it's different (>> instead of >). this is because now that the file is already created with the time inside it, i don't want to overwrite it, instead i want to append to it, so i use the >> pipe instead of the > one. (expereiment with this and you'll see what i mean). i do this command a few times to get good white space between the time and ipconfig, so it's easier to read.

then, i do ipconfig /all to get all ipconfig output (in case a simple ipconfig doesn't give me what i want) and use the >> pipe to again write to the end of the file without overwriting it. once the batch file finishes with this command, it exits and i have what i want.


as for practical use with this, and to help explain the %computername% bit, i wrote this to map my school's network, and according to my past research, the school's PCs had unique computer names, so to make this program compatible for different computers, i used the %computername% environment variable to name the different text files so i could tell them apart (because the computername plays a part in windows networking, and they need to be unique). run this batch file on different computers, and you'll see. or just run an echo %computername% command.

so, that should do it and explain it. any questions?
ASPARTAME: in your diet soda and artificial sweeteners. also, it's obviously completely safe. it's not like it will cause tumors or anything. >.>
always remember: guilty until proven innocent
Jdogg





Posts: 184
Joined: Thu Aug 31, 2006 3:18 pm

Post by Jdogg »

Tural wrote:You know, your local IP is useless to anyone not on your network, there's no reason to even block it out...

On top of that, it clearly says 192.168.1.55 =x
wrong! :P its 35 haha

ANYWAY thanks guys!!
Post Reply