• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3517
  • Last Modified:

Batch File Argument

I want a dos batch file  that doing this;

from dos prompt:
c:\> run-xx-yy.cmd 1

the dos-batch-file will looks like this


@ECHO OFF
Select case
  case 1
      run iexplore.exe "http://webpage1"
  case 2
      run iexplore.exe "http://webpage2"
  case 3
      run iexplore.exe "http://webpage3"
  case else
     ' nothing
end select


Hopes my psesudo VB code are understandable.

thank's in advanced!
0
dingir
Asked:
dingir
  • 2
1 Solution
 
Steve KnightIT ConsultancyCommented:
Well in a batch file "%1" gets the first argument so your batch file could be something like:

@echo off
if "%1"=="" echo You need to supply an argument & goto :eof
if %1==1 iexplore "http://webpage1" & goto :eof
if %1==2 iexplore "http://webpage2" & goto :eof
echo No number matched & goto :eof

etc.

or using a temporary variable:

@echo off
if "%1"=="" echo You need to supply an argument & goto :eof

 set webpage=
 if %1==1 set webpage=webpage1.url.com
 if %1==2 set webpage=webpage1.url.com

if not "%webpage%"=="" echo No number matched & goto :eof
iexplore "http://%webpage%"

Steve
0
 
dingirAuthor Commented:
Outstanding!
And to share with the world (if anyone more needs it)


Batch file
-----
if "%1"=="" echo You need to supply an argument & goto :eof

REM 1 - create xinvoice
if %1==1 D:\xy.vbs "http://xy:718/?cmd=xxyy" & goto :eof

REM 2 - recieve payments
if %1==2 D:\dbs\xy.vbs "http://xy:718/?cmd=xxyy2" & goto :eof

REM 3 - recieve status
if %1==3 D:\dbs\xy.vbs "http://xy:718/?cmd=xxyy3" & goto :eof

echo No number matched & goto :eof
:eof
---------

And the vbs file xy...
---------
Dim objRequest, URL
Set objRequest = CreateObject("Microsoft.XMLHTTP")
URL = Wscript.Arguments.Item(0)
objRequest.open "POST", URL , false
objRequest.Send
Set objRequest = Nothing
---------
0
 
Steve KnightIT ConsultancyCommented:
No problem, glad it worked for you.

Steve
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now