|
Answer» Hi everybody.
I am a NEWBIE and need a little help.
I am writing a batch file that needs to be dynamic. Essentially, I need to remove all +h and +r attributes in a directory and its subfolders/files. However, the directory will be different for each RUN of the batch file.
I would like to run the batch file, and have it ASK the user which directory to choose.
Here is what I have, which when I copy and paste the new directory before running works just fine. I would rather not have to do this, and instead be given an option, whether it be GUI based or not:
cls @ECHO OFF ECHO. *********************************** ECHO. ** Removes Attributes ** ECHO. ******************************* ATTRIB -R -H "\\Server1\DATA\Ken\300\00-Clear\*.*" /S /D cls EXIT
So the variable that changes would be \Ken\300\00-Clear
If I could point and click or copy and paste as it runs, that'd be very helpful.
Thanks
lksi_ken,
If you run WinNT (may also work in Win2000 and WinNT) then you can use the function [highlight]:choiceListInput[/highlight] described in: [highlight]http://www.cmdtips.com/dostips/DtCodeFunctions.php#_Toc128586397[/highlight]
Copy the function at the end of you batch file. Add GOTO:EOF right before the function so that your batch doesn't run into the function when it's supposed to finish.
Call the function like this:
set choiceList= set choiceList=%choiceList%\Ken\300\00-Clear, set choiceList=%choiceList%\Paul\300\00-Clear, set choiceList=%choiceList%\Sam\300\00-Clear, set var= call:choiceListInput var choiceList "Pick a number:" echo.You selected: %var%
You will get a menu like this:
Pick a number: 1 - \Ken\300\00-Clear 2 - \Paul\300\00-Clear 3 - \Sam\300\00-Clear Make a choice or enter a new value [\Sam\300\00-Clear] : You can choose a number or enter a new directory name that is not in the list. If you just HIT enter then the LAST list entry will be chosen.
Dos It Help? Dos It Help,
That did not seem to work for me. We are running XP Pro on our network (not NT or 2000). I'm not sure if that is the problem, or if it is me.
I was never given the option to choose or input.
I kept my batch file, and inserted the mentioned commands before...
cls exit
When that did not work, I also edited it to insert the commands after: cls exit
and then finally, I edited it to add cls and exit at the very end and before the commands you mentioned.
Any help would be appreciated. ThanksTry adding:
setlocal ENABLEEXTENSIONS
at the beginning of the batch file, i.e.:
@echo off [highlight]setlocal ENABLEEXTENSIONS[/highlight] set choiceList= set choiceList=%choiceList%\Ken\300\00-Clear, set choiceList=%choiceList%\Paul\300\00-Clear, set choiceList=%choiceList%\Sam\300\00-Clear, set var= call:choiceListInput var choiceList "Pick a number:" echo.You selected: %var%
|