Topic: 7zip command line question and System Variables? (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=30614" title="Pages that link to Topic: 7zip command line question and System Variables? (Page 1 of 1)" rel="nofollow" >Topic: 7zip command line question and System Variables? <span class="small">(Page 1 of 1)</span>\

 
CPrompt
Maniac (V) Inmate

From: there...no..there.....
Insane since: May 2001

posted posted 10-24-2008 20:04

Greetings all. I am using 7zip to compress some files via batch script. Here is the batch script

code:
@echo off

set tdtd=none
set ttrn=none

for /F "tokens=2-4 delims=/ " %%i in ('date /t') do set tdtd=%%i%%j%%k
for /F "tokens=5-8 delims=:. " %%i in ('echo.^| time ^| find "current" ') do set ttrn=%%i%%j%%k%%l
set tufn=%tdtd%%ttrn%

7z a -tzip %tufn%.zip @listfile.txt



This does a great job at making the directories and files I have listed in listfile.txt as a zip file.

Now for some reason when I add this code :

code:
copy *.zip "C:\Program Files\7-Zip\backup"



It doesn't copy them. That works by itself, but not in the above script. Not sure why. Any ideas?

Also, I'd like to have the command 7z as a system variable but can't figure out how to get that working in Windows. I added it (at least I thought I did correctly) to the Environment Variables, but it doesn't call it straight from the command line. I have to be in that directory. Any ideas on that one?

Thanks in advance!

Later,

C:\

liorean
Paranoid (IV) Inmate

From: Umeå, Sweden
Insane since: Sep 2004

posted posted 10-24-2008 20:42

About the first question: Is the current path the same as the path you are producing the archive files in? If the answer is yes, I'm a bit stumped for ideas. It could be that 7zip just starts the compression in the background and returns directly and thus hasn't created the archives yet, but that's unlikely for a command line tool.

You can modify the Path environment variable under Control Panel:System Properties:Advanced:Environment Variables to include the 7zip directory.

--
var Liorean = {
abode: "http://web-graphics.com/",
profile: "http://codingforums.com/member.php?u=5798"};

CPrompt
Maniac (V) Inmate

From: there...no..there.....
Insane since: May 2001

posted posted 10-24-2008 22:02

thanks liorean,

I have fixed the system variable. I forgot to put it in the PATH section

As for the other, I am still not sure why it's not copying the files except unless like you said, it's not done making the archive. I did make another bat file that just has the copy command, and then a third bat file called "doall.bat" that just has

CALL 7z.bat
CALL copyfiles.bat

and it works. Go figure...

Later,

C:\

CPrompt
Maniac (V) Inmate

From: there...no..there.....
Insane since: May 2001

posted posted 10-24-2008 22:31

OK...after adding it to the system variable (correctly I might add), restarting the computer, it now all works with one file just like it should.

So...thanks all

Later,

C:\

CPrompt
Maniac (V) Inmate

From: there...no..there.....
Insane since: May 2001

posted posted 10-31-2008 15:07

OK...the script works, but, if I am not logged into the computer, the Scheduled Task that I set up does not start.

The log says this :

quote:

** ERROR **
The attempt to log on to the account associated with the task failed, therefore, the task did not run.
The specific error is:
0x80070569: Logon failure: the user has not been granted the requested logon type at this computer.
Verify that the task's Run-as name and password are valid and try again.



But the username and pass that I used is the local administrator of the computer. So, do I have to do something special for that login?

Thanks in advance!

Later,

C:\



Post Reply
 
Your User Name:
Your Password:
Login Options:
 
Your Text:
Loading...
Options:


« BackwardsOnwards »

Show Forum Drop Down Menu