Solved

Batch file add a parameter

Posted on 2006-11-01
5
1,016 Views
Last Modified: 2007-12-19
my batch file:ungz.bat
c:\share\pacl\paext -p"c:\share\archive" c:\share\winzip100.exe.gz
del c:\share\winzip100.exe.gz

I call it with CMD c:\share\ungz.bat

I want to pass it a filename:

call it with CMD c:\share\unzip.bat myfile.gz

and have it do this:
c:\share\pacl\paext -p"c:\share\archive" c:\share\myfile.gz
del c:\share\mfile.gz
0
Comment
Question by:MacNuttin
  • 2
  • 2
5 Comments
 
LVL 12

Accepted Solution

by:
guidway earned 50 total points
Comment Utility
Parameters are passed into batch files using the %<some number> syntax,

for instance the first parameter would be assigned %1

Example:
c:\share\pac\paext -p"c:\share\archive" %1
0
 
LVL 10

Expert Comment

by:GuruGary
Comment Utility
%1 would be the first parameter of a batch file, %2 is the 2nd, etc.

So if I understand your question, I think you want your batch file to be:
c:\share\pacl\paext -p"c:\share\archive" %1
del %1
0
 
LVL 11

Author Comment

by:MacNuttin
Comment Utility

so this?

@echo off
   ::ungz.bat
   ::Usage command [command parameters]
   REM This script decompresses gz files and puts them in the achive
   c:\share\pac\paext -p"c:\share\archive" %1
   del c:\share\ %1
   :EOF
0
 
LVL 12

Expert Comment

by:guidway
Comment Utility
that should work
0
 
LVL 11

Author Comment

by:MacNuttin
Comment Utility
problem with del path tried this and it does ok but I have pass it the filename with it's path

@echo off
   ::ungz.bat
   ::Usage command [command parameters]
   REM This script decompresses gz files and puts them in the achive
   c:\share\pacl\paext -p"c:\share\archive\" %1
   cd share
   del %1
   :EOF
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/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…
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video discusses moving either the default database or any database to a new volume.

762 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

10 Experts available now in Live!

Get 1:1 Help Now