8

Create a loop in a batch file

 2 years ago
source link: https://www.codesd.com/item/create-a-loop-in-a-batch-file.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Create a loop in a batch file

advertisements

I need a batch file where a user enters a password and if it is correct it maps a drive. If it is wrong then it needs to go back to the start

I have this

:start
echo    Username=****

SET /P password=Please enter the password

IF %password%==password goto map
IF %password%!==!password goto start

:map

NET USE Z: \\server\folder

It works if the password entered is correct, but doesnt if it is wrong

Any help?


You don't need IF %password%!==!password goto start altogether. If the password is ok, then goto map, otherwise goto start. That is if you replace IF %password%!==!password goto start with goto start you'll get what you want.

Tags batch-file

Related Articles

Define the iMacros loop in the batch file

I want to create an art of a batch file, where you can set a variable loop, and the iMacros run variable times. Anybody has an idea how to write this on a batch file? I already know how to start a iMacro over a batch, but not how to make it loop and

How do you create a journal using a batch file?

I was wondering how do you create a journal using a batch file? I want to be able to save my journal entries and create a date. I would like to save it using a .log file if it is possible. I have to code for the journal itself below. :JOU ECHO ====Jo

For a loop in a batch file reading a File Paths file

I want to write a Windows batch file script that will loop through a text file of FILE PATHS, do some work using data from each file path, then ultimately delete the file. I started by running the FORFILES command and sending its output (the @PATH pa

How to use FOR loops embedded in batch files

I have some code in which I want to use a FOR loop to handle a set of files. As part of handling a file there's a FOR /F loop that reads it and appends data to an other file based on the file name. In order to be able to set the output file name I ha

How to end a VBS file called from a batch file and loop through the batch file

Currently I have a batch file that calls a VBScript and executes the script and exits from that script into the command prompt window that I called the batch file from. I am wanting to return to the batch file from the VBScript and loop back into the

Create an event with the batch files

Here's what i want to achieve. We have this email archive database which we optimize on a weekly basis . At the moment we are manually logging in run the command and monitor the status. The optimization can take anywhere between 3-12 hours which is m

How to set a timestamp when copying files in the for loop to the batch file

Help please! I am new to the batch files and have a very specific question. I am trying to copy many files in multiple subdirectories into a single directory via a for loop and in the meantime attache a timestamp to each name (because all the files h

How to divide the string without the for loop in the batch file

I want to split a string in two parts, without using any for loop. For example, I have the string in a variable: str=45:abc I want to get 45 in a variable and abc in another variable. Is it possible in batch file? pattern is like somenumber:somestrin

Django creates a superuser from a batch file

I'm trying to make a batch file that runs syncdb to create a database file, and then create a superuser with the username "admin" and the password "admin". My code so far: python manage.py syncdb --noinput python manage.py createsuperu

How can I use special characters to create a folder in a batch file?

@echo off setlocal EnableDelayedExpansion set "folder=C:\Test\Test01\Test02\Test03\Test04\!!Test05\Test06" md %folder%\Final echo %folder% pause This will create in C:\Test\Test01\Test02\Test03\Test04\Test05\Test06\Final. Result should be like C

How to create a MAP reader by batch file

often i have to create map drive where i specify machine and user credential. now i like to know can we write a batch file which will create map drive and where i provide all details like pc and folder location and user credentials etc. i got one as

Unable to create zip using 7z in batch file

Here i'm using batch file to take backups & then zip those backups.Backup process successfully.But zipping process failed and it always show to install the 7zip.But i already installed 7ip. Here goes my code @ECHO OFF osql -S .\sqlexpress -E -i "

copy all items from one folder to another folder using a loop in a batch file

I want to copy all the files of a folder into some other folders using batch script. Say, I have two folders named folder1 and folder2. these two folders are located in C:\Users\xyz . I want to copy the elements of another folder (say, folder3 which

How to create a script via a batch file that will uninstall a program if it was installed on Windows 7 64-bit or 32-bit

I am in a small bind. The program in question can be installed in the program files directory (64bit) or X86 path. The program is already installed in over 200 machines. I am fairly certain the default install path was X86 as that's the default. I am

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK