Solved

Batch file add a parameter

Posted on 2006-11-01
5
1,022 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

863 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

22 Experts available now in Live!

Get 1:1 Help Now