Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Batch file add a parameter

Posted on 2006-11-01
5
Medium Priority
?
1,046 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
[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
  • 2
5 Comments
 
LVL 12

Accepted Solution

by:
guidway earned 200 total points
ID: 17855281
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
ID: 17855297
%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
ID: 17855299

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
ID: 17855401
that should work
0
 
LVL 11

Author Comment

by:MacNuttin
ID: 17855627
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

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

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…
One of my most closely kept secrets is revealed in this discussion How to output text on the same line This question was recently posted in EE by Simon336697 (http://www.experts-exchange.com/Programming/Languages/Scripting/Shell/Batch/Q_2459…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

609 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