Batch file does not execute PKZip

Pkzip / 2.04
June 23, 2010 at 07:20:38
Specs: Windows Vista
Hello,
I am trying to automate zipping of a daily backup excel file using Task scheduler to run batch file. When the batch file is executed by the scheduler, it gives the following error:

"pkzip is not recognized as an internal or external command, operable program or batch file."

However, when I manually execute the batch file, it runs perfectly.

The batch file contains the following one line:

pkzip -a -m VBT.zip *.xls

Any help will be greatly appreciated.

Note: pkzip.exe is located in the same folder where I am running the batch file.

Thanks,
Masuta


See More: Batch file does not execute PKZip

Report •

#1
June 23, 2010 at 08:27:46
Try including the path info for pkzip (even though it's in the same folder), just in case. For example:

c:\directory1\directory2\pkzip -a -m VBT.zip *.xls

And you're using pkzip with vista?

You're not really green until you're soylent green.


Report •

#2
June 23, 2010 at 08:42:42
You should specify an absolute path to pkzip.exe and any files it will access. When you manually run the command you have navigated to the folder in question and made it the current directory. When run under Task Scheduler the current directory is likely to be something very different. You cannot make any assumptions about what it will be.

You could also set the current directory in the backup script.


Report •

#3
June 23, 2010 at 11:33:44
Hi Guys,

Thanks for your quick reply. I did as you suggested. It did help to start pkzip. However, following new error came up.

Note: I am typing everything as I cannot copy paste the screen shot here.

c:\windows\system32>c:\backup\valtracking\pkzip -a -m VBT.zip *.xls

PKZIP <R> FAST! Create/update Utility Versio 2.04g 02-01-93......etc..etc......

80486 CPU detected.
XMS version 2.00 detected.
DPMI version 0.90 detected.
Using Normal Compression.

Creating ZIP: VBT.ZIP

PKZIP: <E12> nothing to do!

What should I do now?

Thanks for your help so far.

Masuta



Report •

Related Solutions

#4
June 23, 2010 at 11:41:53
Are the .XLS files in the c:\backup\valtracking directory?

You're not really green until you're soylent green.


Report •

#5
June 23, 2010 at 11:48:41
Hi Dave,

Sorry, I should have provided that info beforehand.

Yes, the XLS file is in the same directory.

Thanks,
Masuta


Report •

#6
June 23, 2010 at 13:36:05
That's the error pkzip will give if it can't find the *.xls files.

Maybe you need a path to the excel files also, something like:

c:\backup\valtracking\pkzip -a -m VBT.zip c:\backup\valtracking\*.xls

but valtracking is a long file/folder name and I don't know that pkzip will recognize it.

I was thinking you could modify the path in a SET PATH statement as the first line in your batch file. That way you wouldn't have to include a path in the pkzip line. For dos that would be:

SET PATH=C:\BACKUP\VALTRACKING;%PATH%

but I don't know if vista accepts that. You can change the path from the desktop with 2000 and XP and maybe vista as well. Here's how it's done for XP:

http://www.computerhope.com/issues/...

You're not really green until you're soylent green.


Report •

#7
June 24, 2010 at 04:04:21
If the pkzip and xls files are in the batch script directory, the following does the job as the ~s modifier returns the 8.3 format pathname and 0 is the batch name.

However I suggest you use under Vista 7za.exe the 7-ZIP command line version that is 32 bit designed (and free).


%~sdp0pkzip -a -m %~sdp0VBT.zip %~sdp0*.xls

or better to avoid to store the pathnames

pushd %~dp0
pkzip -a -m VBT.zip *.xls
popd


Report •

#8
June 24, 2010 at 07:07:24
Hi Dave,

I used the SET PATH statement as the first line in the batch file. I removed the path in the pkzip line. When I executed the batch file using the task scheduler, pkzip started but it did not create any zip file. The following message appeared:

c:\windows\system32>pkzip -a -m VBT.zip *.xls

PKZIP <R> FAST! Create/update Utility Versio 2.04g 02-01-93......etc..etc......

80486 CPU detected.
XMS version 2.00 detected.
DPMI version 0.90 detected.
Using Normal Compression.

Creating ZIP: VBT.ZIP

PKZIP: <E12> nothing to do!

I also changed the folder name to VBTRACK (8 digits) to see if long folder name is causing the problem, but it did not help. I keep getting the same error message.

Hi IVO,

As per your suggestion, I used the ~s modifier. But when I run the batch file, it gives me this error: The directory name is invalid.

I cannot use any other zipping utility as I cannot install any programs on this computer. It is my work computer.

I can only use a standalone application that does not require installation such as PKZip. 7za.exe requires installation so I cannot use it.

If you know any other application that can replace pkzip and do not require installation, please advise.

Another question, can the compression utility built into Vista be used to do this job? If yes, please provide me the steps on how to set up batch file to run the built in compression utility. If this can be done, then I do not need any third party compression software.

Thanks a lot to all of you for your help so far.
Masuta


Report •

#9
June 24, 2010 at 08:52:11
You're running pkzip from the c:\windows\system32 directory. The OS is finding pkzip.exe baecause of the path statement but it's looking for the files in c:\windows\system32 and not c:\backup\valtracking because that directory isn't specified. So I was wrong above, you still need to specify a path to the files. So it should be something like:

pkzip -a -m c:\backup\valtra~1\VBT.zip c:\backup\valtra~1\*.xls

The first c:\backup\valtra~1 tells pkzip where to put the zip file, otherwise it dumps it in the windows\system32 directory (unless that's where you want it). The second tells pkzip where to find the files.

That's with the added path statement so it finds pkzip.exe without a path prefix.

The valtra~1 should be the 8.3 format that pkzip will recognize. But the OS may not assign ~1 to the folder name. It could be ~2 or ~3 depending on if it's assigning more than one folder in 8.3. So if the ~1 doesn't seem to work then permanently changing valtracking to something 8 letters or less is the way to go.

I'm not familiar with Vista's options for compression or the software that IVO recommended.

You're not really green until you're soylent green.


Report •

#10
June 24, 2010 at 12:03:48
Please, re-read *carefully* my post #7 and use the code at the bottom.

If you are interested the 7za.exe command line I suggested is a standalome application that reqires no installation. Send me a private message with your e-mail address and I am glad to give you the program.


Report •

#11
June 25, 2010 at 06:27:52
Hi IVO,

Thanks for 7za.

I tried the following code (using pkzip) suggested by you:

pushd %~dp0
pkzip -a -m VBT.zip *.xls
popd

AND it worked!! Thanks a lot.

I have one question regarding 7za. Do you know the switch which will move the file into the archive instead of copying it into the archive. (the equivalent switch for pkzip is -m)

I tried the 7za provided by you. It works perfect but the excel file is still sitting there after the archive is created. This way lot of space is wasted considering the fact that I am archiving daily.

Thanks a lot to all of you for the wonderful support.
Masuta


Report •

#12
June 25, 2010 at 12:48:57
As I said I do not master 7ZA switches as i just use the tool to Archive, Extract or List files, i.e commands A, E and L.

As far as I know there is no option equivalent to Moving the files into the archive. So you have to DEL them if all is OK, but this requires a complex code far beyond your present knowledge.

Run pkzip freely if no LFNs are to be processed and keep 7ZA as an alternate tool if needed.


Report •

Ask Question