| 1. |
Solve : How to determine what parameter passed to a batch and do something base on it.? |
|
Answer» Hello All, erobby, lookingforhelp, it is CLEAR you do not yet understand about batch parameters. You cannot "test them interactively from the command line". %1, %2, %3, etc are special variables that a batch file can use while it is running. They can't be set by the user as you tried to do. Consider the following batch file which we will call param.bat. Code: [Select]@echo off echo parameter 1=%1 if "%1"=="cat" echo a %1 says Meow! if "%1"=="dog" echo a %1 says Grrrrr! if "%1"=="" echo no parameter passed Save it into a folder as param.bat Now open up a command window in that folder. at the prompt type : Code: [Select]param cat then type Code: [Select]param dog then type Code: [Select]param Now do you see? Dias, Thanks I had already figured that out with erobby response. Anyway. In case you didn't realized it, the tone of your reply was rude and disrespectful. While we would appreciate you responding to our post, I don't believe you're obligated to answer anyone post if you don't feel like it. I believe many people here are asking questions because they don't know or not sure how it should work. Next time you decide to response to a post keep this in mind, try to show some respect to your fellow forum members. I am sure what you know can be learned by anyone. The fact that we don't know/understand it yet, doesn't mean we are idiot. quote author=Dias DE verano link=topic=62085.msg394315#msg394315 date=1216883718] Quote from: LookingForHelp on July 23, 2008, 08:22:07 PM erobby, lookingforhelp, it is clear you do not yet understand about batch parameters. You cannot "test them interactively from the command line". %1, %2, %3, etc are special variables that a batch file can use while it is running. They can't be set by the user as you tried to do. Consider the following batch file which we will call param.bat. Code: [Select]@echo off echo parameter 1=%1 if "%1"=="cat" echo a %1 says Meow! if "%1"=="dog" echo a %1 says Grrrrr! if "%1"=="" echo no parameter passed Save it into a folder as param.bat Now open up a command window in that folder. at the prompt type : Code: [Select]param cat then type Code: [Select]param dog then type Code: [Select]param Now do you see? [/quote]Lookingforhelp, you are the rude and disrespectful one! I think you should modify your attitude. My post was clear and helpful. Having read your post, I think your English is maybe not good enough to understand that I was not being rude. |
|