[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1049
  • Last Modified:

Batch file add a parameter

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
MacNuttin
Asked:
MacNuttin
  • 2
  • 2
1 Solution
 
guidwayCommented:
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
 
GuruGaryCommented:
%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
 
MacNuttinAuthor Commented:

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
 
guidwayCommented:
that should work
0
 
MacNuttinAuthor Commented:
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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now