

InterviewSolution
Saved Bookmarks
1. |
Solve : To count Command line arguments (Paramaters) in .Bat file.? |
Answer» <html><body><a href="https://interviewquestions.tuteehub.com/tag/hi-479908" style="font-weight:bold;" target="_blank" title="Click to know more about HI">HI</a> all!!!!!!!!!<br/><br/>I am <a href="https://interviewquestions.tuteehub.com/tag/sending-1200600" style="font-weight:bold;" target="_blank" title="Click to know more about SENDING">SENDING</a> some parameters to a .bat file through command line. I want the count of that parameters means how many parameters I am passing. If i will enter less than the sufficient then the message should <a href="https://interviewquestions.tuteehub.com/tag/get-11812" style="font-weight:bold;" target="_blank" title="Click to know more about GET">GET</a> prompted to the user.<br/><br/>Can anyone please give me the solution.<br/><br/><br/><br/>thanks.You can check if a parameter is a null string<br/><br/>For example if you are expecting four parameters...<br/><br/>if "%<a href="https://interviewquestions.tuteehub.com/tag/1-236780" style="font-weight:bold;" target="_blank" title="Click to know more about 1">1</a>"=="" (<br/> echo parameter 1 is missing<br/> goto end<br/> )<br/><br/>if "%2"=="" (<br/> echo parameter 2 is missing<br/> goto end<br/> )<br/><br/>if "%3"=="" (<br/> echo parameter 3 is missing<br/> goto end<br/> )<br/><br/>if "%4"=="" (<br/> echo parameter 4 is missing<br/> goto end<br/> )<br/><br/>REM if you get here 4 parameters were passed<br/><br/>REM HERE IS YOUR CODE<br/><br/>:end<br/>Thanks !!!!!!!!!!!!!!<br/><br/>It's working fine for me.<br/><br/>Thanks again.</body></html> | |