Windows 7 Forums

Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: .bat file, batch coding simple variable use

30 May 2014   #1
Skylais

Microsoft Windows 7 Ultimate 64-bit 7601 Multiprocessor Free Service Pack 1
 
 
.bat file, batch coding simple variable use

Code:
@echo off
color C
SET IPaddress=0
set /p IPaddress=Please enter the destination Ip Address:
color A
ping IPaddress
pause
okay, so i want the IPaddress variable to be used as the ipaddress to be pinged. When i run this, it is ineffective. Can someone teach me as why and how to properly code this?

Actually i just figured out how to reference the variable with modulus/percentage symbols.
%IPaddress%


My System SpecsSystem Spec
.
30 May 2014   #2
UsernameIssues

W7 Pro SP1 64bit
 
 

Quote   Quote: Originally Posted by Skylais View Post
~~~
Actually i just figured out how to reference the variable with modulus/percentage symbols.
%IPaddress%
Does this mean that you no longer need help?

You might also want to make the batch file loop back to the start.
My System SpecsSystem Spec
31 May 2014   #3
Skylais

Microsoft Windows 7 Ultimate 64-bit 7601 Multiprocessor Free Service Pack 1
 
 

Actually do you mind showing me a basis on such a loop. Also if you know anywhere i could learn this simple type of batch coding, could you please link me to it
My System SpecsSystem Spec
.

31 May 2014   #4
UsernameIssues

W7 Pro SP1 64bit
 
 

Here is a loop that I use:

Code:
:start
ipconfig/all
pause
goto start
For the ping batch file in your post, you might also want to tell the user how to enable quick edit so that they can quickly paste the IP address in... as opposed to typing it in or using the slower/default paste. Right click on the title bar of an open cmd window - then select properties - and look around.

Try this website:
Getting started with batch files

edit: there is not a space between ipconfig and the switch /all.
That space is optional. I tend not to put it there.
My System SpecsSystem Spec
Reply

 .bat file, batch coding simple variable use




Thread Tools Search this Thread
Search this Thread:

Advanced Search




Similar help and support threads
Thread Forum
Can a property from a .properties file be made into a usable variable?
I have code to read out lines from .properties, but it just prints it out, because im an idiot and didn't notice till now. So, the question is, can it be made into a variable instead? current code; Properties prop = new Properties(); InputStream input = null; try { input = new...
Software
How to run a batch file at logoff & some batch scripting help please
Hiya, I'd just like to run a simple batch file at logoff to backup some settings. I plan to use Robocopy, which is what i use to more thorough backups. Two questions: 1. How make it run by clicking Start > Shutdown? (i realise i could make a shutdown batch file and run it instead, but i'd...
Backup and Restore
Batch File that grabs file names from folder to insert into batch file
Ok I'm totally at a loss on how to word this so I'm just going to write it out the best that I can... :confused: First I have a batch file that I'm writing that will convert mp4 files to mp3 files (I have a lot) for a buddies band using ffmpeg. Here's the code that I'm using: ffmpeg -i...
General Discussion
a simple batch file for copy files and folders
I want to write a batch file that do this for me: - makes a directory with the "yy.mm.dd.hh.mm" as the directory name, - copies files and folders from a TEST directory to above destination, - copies only new (or modified) files from the TEST directory to a separate folder. Any Idea?
General Discussion
Need help creating a .bat file moving output into a variable
Hello everyone, I am looking to create a .bat file to automate task that I need to do about a thousand times. I have some experience with .bat files, however I would still consider myself a beginner. I also didn't really see a good forum for something like this so if it need to be moved I...
General Discussion
Open Multiple Files one click - simple bat/batch file
Hey, I have a simple batch file to load multiple files with one click, but it's not working. When I run it, it simply very quickly pops up the cmd dialog, which quickly disappears, and nothing is loaded. I've tried 'running as administrator' - same problem. File is xxxxx.bat
General Discussion


Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 08:43.

Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App