5 replies
by kevin
showip.bat -
ipconfig
pause
I just wrote a tiny C program to display the IP address for my colleagues here at work. I wrote it at home on my own time and PC so I can give it to you free if you're interested.
Ralph
by mitgat
open up notepad then copy and paste this in it
@echo off
cd c:\windows\system32
ipconfig.exe /all
pause
then save it ip.bat
by cward
You were given commands to show the IP address but not provided with a solution to your original request. None of these write the information to a text file. Please note, I support educating the user and may consider providing them with instructions on how to open a command prompt and type in ipconfig. That's really all you need to do.
What I'm surprised is nobody asked you why this was needed? Perhaps there is a better solution knowing the full subject of your issue?!
You also didn't state if they would need this when they logon or if they need it more than once a day. If only once a day and only when they logon, then it could be a single file in a logon script or part of one. And, if they needed it more than once, it could also be automated to put the results in a specified area with a shortcut for review. It would be updated each time they logon. However, to answer your request and provide full details explaining my solution, I offer this.
open a command prompt (Start/Run/CMD)
Note: press return after each command - Items in parenthesis are comments
cd \windows\system32
(If the system was upgraded from Windows NT the windows directory (%systemroot%) might be winnt - if so, use this command: cd \winnt\system32)
dir ip.*
(make sure there is not a file named ip.cmd before creating this file. If so, rename the calling file from ip.cmd to somefilename.cmd where somefilename means to name it anything else i.e. ipaddr.cmd)
(Now create the command 'batch' file)
copy con ip.cmd
@echo off
echo | more | ipconfig | find "IP">c:\ip.txt
notepad c:\ip.txt
^Z
(above line is created by pressing the F6 key - you should get a response of 1 file(s) copied on the next line. You cannot type in ^Z directly. ^Z is used as an end of file marker and informs the OS you are finished writing directly to the disk.)
I chose to put the file in the %systemroot%\system32 directory because it is on the path and can be called from any directory(folder). You can also create a shortcut to this file easily through Windows Explorer.
The file is put in the root of the c: drive so files are not created all over your drive when running this from other directories.
copy con ip.cmd is defined as copy from the console (keyboard) to the file called ip.cmd.
@ hides the current line from being echoed to the screen.
Appending off to @ turns off all subsequent echoes to the screen.
The | symbol is the created by holding down the shift key and pressing the \ (backslash) key. It is called the pipe symbol. On a command line, this separates different commands.
Putting the file in a common place allows notepad, which is also on the path, to load the file you just created.
Since there is only 1 > (greater than) symbol used the file will be overwritten each time it is executed.
Windows NT and above use .cmd file extensions similar to .bat extensions.
Using CMD instead of COMMAND to open a prompt is different. COMMAND is backward compatible to earlier versions of Windows (pre NT) and it tied to real memory and suffers from the same enviroment issues. CMD is not affected.
The echo line will result in a smaller response removing the DNS suffix, subnet mask and default gateway from the report.
I could have just given you the 3 lines to put in your file but then that would only help you on this issue. Explaining my solution may help you in the future.
Good luck.
This discussion is closed to new replies.
Trending Software posts
Sort by Trending