Solved

Batch File Argument

Posted on 2009-04-01
3
3,488 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

TOMORROW TOMORROW.BAT is inspired by a question I get asked over and over again; that is, "How can I use batch file commands to obtain tomorrow's date?" The crux of this batch file revolves around the XCOPY command - a technique I discovered w…
Being a system administrator some time we require to do things remotely, one of them is installing software. Here I am going to tell you how to install software through wmic (Windows management instrument console). I am not at all saying that this i…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

705 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now