Batch File

A Place For Programmers Of All Levels To Discuss Programming & Web Building.

Moderator: Community Moderator

Post Reply
sagent64
Sergeant
Sergeant
Posts: 129
Joined: 14 Aug 2010, 03:24
Has thanked: 3 times

Batch File

Post by sagent64 »

:shoot: Hi , i want to make a script on command line that will show my IP address , Computer Name , Windows User Account , Date
is there anyone can share it here?...
or any more code can add?
i also want to know how to use Looping decrements -- like 5 4 3 2 1 in command prompt

any answer ,url w'd appreciated
Thanks
User avatar
srego
Warrant Officer
Warrant Officer
Posts: 399
Joined: 23 Nov 2010, 03:55
Location: land were no gods
Has thanked: 3 times
Been thanked: 5 times

Re: Batch File

Post by srego »

I just created this for you, im using windows 8.1
to create a batch file, just open a note pad and save the file to filename.BAT
or in windows xp or 7 at command prompt just type: edit filename.BAT
:thumbup:
just copy and paste this script:


@echo off
set ip_address="IPv4 Address"
for /f "usebackq tokens=2 delims=:" %%f in (`ipconfig ^| findstr /c:%ip_address%`) do @echo Your IP Address is: %%f
@echo Domain: %USERDOMAIN%
@echo User: %USERNAME%
@echo Date: %DATE%
@echo Time: %TIME%
set counter=5
:loop
@echo Countdown: %counter%
set /a counter=%counter%-1
if %counter% EQU 0 goto exit
goto loop
:exit
@echo here is what you asked from ChattChitto by Srego
Image
Image
User avatar
LghPuppy
GFX Team
GFX Team
Posts: 40381
Joined: 06 Jun 2011, 21:25
Location: Watering the trees
Has thanked: 127 times
Been thanked: 81 times

Re: Batch File

Post by LghPuppy »

Nice Srego.
Image
Please consider Donating
“The only thing necessary for the triumph of evil is for good men to do nothing.”
Edmund Burke
User avatar
MrNiitriiX
Premium Uploader
Premium Uploader
Posts: 2197
Joined: 19 Apr 2010, 14:52
Location: between space and time
Has thanked: 24 times
Been thanked: 164 times

Re: Batch File

Post by MrNiitriiX »

try theis for your first question:

Code: Select all

@ECHO OFF
IPCONFIG |FIND "IP"
@echo --------------------------------------------------------
@echo Domain: %USERDOMAIN%
@echo --------------------------------------------------------
@echo User: %USERNAME%
@echo --------------------------------------------------------
@echo Date: %DATE%
@echo --------------------------------------------------------
pause
also found this on the net for more details:

Code: Select all

@echo off
echo Checking your system information, Please wating...
systeminfo | findstr /c:"Host Name"
systeminfo | findstr /c:"Domain"
systeminfo | findstr /c:"OS Name"
systeminfo | findstr /c:"OS Version"
systeminfo | findstr /c:"System Manufacturer"
systeminfo | findstr /c:"System Model"
systeminfo | findstr /c:"System type"
systeminfo | findstr /c:"Total Physical Memory"
ipconfig | findstr IPv4

echo.

echo Hard Drive Space:
wmic diskdrive get size

echo.
echo.

echo Service Tag:
wmic bios get serialnumber

echo.
echo.
echo CPU:
wmic cpu get name

echo Completed! 
pause 
And to creat a loop in batch just type :a and goto a .... for example

Code: Select all

@ECHO OFF
echo My name is sagent64
:a
echo and i know you love me
goto a
Last edited by MrNiitriiX on 21 Apr 2014, 04:51, edited 1 time in total.
"Injustice anywhere is a threat to justice everywhere." - Martin Luther King
Image
Upload List
sagent64
Sergeant
Sergeant
Posts: 129
Joined: 14 Aug 2010, 03:24
Has thanked: 3 times

Re: Batch File

Post by sagent64 »

how about sending messege to the host ? or ip address connected to your net view ? ...

can we also let this post open so Manny people could share and learn from other skills in batch filesss
User avatar
srego
Warrant Officer
Warrant Officer
Posts: 399
Joined: 23 Nov 2010, 03:55
Location: land were no gods
Has thanked: 3 times
Been thanked: 5 times

Re: Batch File

Post by srego »

first you need to enable your net messenger services.

to send a message to a computer PC1

Code: Select all

net send PC1 "hello"
to send a message to the whole workgroup

Code: Select all

net send * "hello everyone"
Image
Image
sagent64
Sergeant
Sergeant
Posts: 129
Joined: 14 Aug 2010, 03:24
Has thanked: 3 times

Re: Batch File

Post by sagent64 »

ok ok thanks .. how about browsing files ? ... and sending files executing files using commandline to the other computer ? ... .
User avatar
srego
Warrant Officer
Warrant Officer
Posts: 399
Joined: 23 Nov 2010, 03:55
Location: land were no gods
Has thanked: 3 times
Been thanked: 5 times

Re: Batch File

Post by srego »

you cant browse. DOS is not a shell. but there are dos programs which is capable of browsing files.
but
you can go to the shared files of a network computer, copy, delete, rename, etc. depending on the network permission


e.g.

Code: Select all

copy 192.168.1.1\sharedfolder\test.txt  D:\test 
Image
Image
sagent64
Sergeant
Sergeant
Posts: 129
Joined: 14 Aug 2010, 03:24
Has thanked: 3 times

Re: Batch File

Post by sagent64 »

ok i have shells so can you tell me how to do it in shell? or tell me the other program ? ..
also the net msg is not working maybe it will work on shell ..
User avatar
srego
Warrant Officer
Warrant Officer
Posts: 399
Joined: 23 Nov 2010, 03:55
Location: land were no gods
Has thanked: 3 times
Been thanked: 5 times

Re: Batch File

Post by srego »

again, you need to enable the net messenger services.
ctrl panel> administrative tools> services> net messenger\
then at the dos
CMD> net start

then you can do net send.

well about shell, if you have one; its probably on its Help.

and uhmmm its been a long time that I was in the world of DOS. and I forgot the name of shell i sometime used.. its something "Norton Disk... ... " i forgot sorry :relieved:
all i remember is i used two before. but I dont really rely on it. as long as you know DOS commands

its kinda hard to share all. because DOS have different versions.

if theres something you want to know, or ask.
then I maybe can do a recall and try to help :icon_smile:

:ok:

-- 22 May 2014, 17:45 --

BTW net send or the net messenger service is only available in XP
as i have said DOS commands depends on its version.
if you are running in vista win7/8
use msg.exe
Image
Image
Post Reply

Return to “Programming/Web Building Chat & Support”