Solved

Batch File Argument

Posted on 2009-04-01
3
3,507 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
[X]
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
  • 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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

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…
YESTERDAY YESTERDAY.BAT is inspired by a previous article I wrote entitled: TOMORROW.BAT (http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/MS_DOS/A_4196-Advanced-Batch-File-Programming-TOMORROW-BAT.html). The crux of this batch f…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

730 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