Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Batch File Argument

Posted on 2009-04-01
3
3,501 Views
Last Modified: 2012-06-27
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
Comment
Question by:dingir
  • 2
3 Comments
 
LVL 43

Accepted Solution

by:
Steve Knight earned 350 total points
ID: 24036743
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
 
LVL 1

Author Comment

by:dingir
ID: 24036779
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
 
LVL 43

Expert Comment

by:Steve Knight
ID: 24036802
No problem, glad it worked for you.

Steve
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
Using dates in 'DOS' batch files has always been tricky as it has no built in ways of extracting date information.  There are many tricks using string manipulation to pull out parts of the %date% variable or output of the date /t command but these r…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question