Computing.Net > Forums > Disk Operating System > batch file require variable or exit

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

batch file require variable or exit

Reply to Message Icon

Name: Jeff
Date: April 10, 2003 at 04:50:58 Pacific
OS: xp
CPU/Ram: Intel 2.8/512
Comment:

Ok..been trying all the things I know and alot of examples from this forum, but I can't seem to "hack" it enough to get what I need.

I wrote a simple batch file with 4 commands to set time on a Win2000 server to use time from a different source/sync to that source then restart time services.

That part works, but I am doing it to allow my different sites to use the same file by running: settime.bat . I do the: settime.bat 10.127.2.1 and use the %1 in the batch file itself to pass the ipa along, and that works, but if you leave out the variable, it still runs....that is the problem I have.

I tried some If stuff like: If %1.==(). GoTo TIME, but honestly, not sure if the () means notnull or not. Any assistance or links would be most appreciated.

Thanks, Jeff



Sponsored Link
Ads by Google

Response Number 1
Name: IVO
Date: April 10, 2003 at 06:10:31 Pacific
Reply:

If I understand, you want to be sure your batch gets the parameter to correctly start, isn't it? If so, put this as the first line:

If not "%1"=="" GoTo TIME
Echo Missing ip address...
GoTo Exit

:TIME

The () is a trick I used to test for the auto-calling of the script. It has no special meanings.
If what I posted is useful, then have a nice day, otherwise post again.


0

Response Number 2
Name: Jeff
Date: April 10, 2003 at 07:35:21 Pacific
Reply:

That was PERFECT Ivo, thanks alot! Didn't think of trying the IF not.



0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Disk Operating System Forum Home


Sponsored links

Ads by Google


Results for: batch file require variable or exit

CMD Batch File Exit www.computing.net/answers/dos/cmd-batch-file-exit/11850.html

Batch Files: set variable to output www.computing.net/answers/dos/batch-files-set-variable-to-output/16926.html

batch file www.computing.net/answers/dos/batch-file/9930.html