Batch File Execution problem

jfk92

Honorable
Jul 10, 2013
3
0
10,510
0
Hi,

First post. I have written a very simple batch file to copy outlook files and the contents of a single folder on a desktop to a shared drive folder on our server. Works great on W7 machines. I've adapted it for XP machines (mainly 7zip executable path as well as outlook files path and designated folder path. The batch file runs - and seems to be working as I see a zip file appear on our shared server folder - but then seems to hang at the end of the compression. Then it will run the zip on the folder contents. The log I created during process shows "Everything OK" at the end of the outlook and folder zip actions. But here is where it is puzzling - the log shows the zip of each item 3 or 4 more times with 'Everything OK' at the end in the log then it finishes and there are NO files on the server folder. It's like it removes them.

I am quite confused! I'd be happy to post the batch file content (or email it) and log content if you wouldn't mind giving me some feedback - I'm more perplexed by the fact that the log shows it running 4 times in completion - than that there is nothing there at the end. I am doing some renaming and then deletion of the files after the zip - it works fine on the W7 machines that way - but perhaps XP is not playing nicely?

Thanks in advance.

John
 

everlost

Honorable
Mar 8, 2013
39
0
10,590
2
looks like your rename syntax is wrong. you may have to copy then rename.

also you can add lines like "date /t >>c:\backuplog.txt" and "time /t >>C:\backuplog.txt" to see what is happening when. to see if its running a command again or just logging it again. the "everything is ok" is just 7zip reporting no errors.

7zip has an update switch/command you could use with your source and compress straight to your destination adding and overwriteing old data as it goes. but i would assume that that will drain your network resources during a backup.

edit - and i still don't know what your %%A is doing, in my tests it returned "unexpected" message. and as a variable, it ran the "do" over and over untill i force stoped. and you seem to be inconsistent in your usage of %userprofile% paths
 

everlost

Honorable
Mar 8, 2013
39
0
10,590
2
we would need the batch file and log file contents. and your windows versions and service pack information (first few lines of system summery in msinfo32).

be mindful of private information your sending.
 

jfk92

Honorable
Jul 10, 2013
3
0
10,510
0


Machine info:
XP - SP3, 32bit
Batch file:
::Create the Log file of bat file execution
::
::
Echo >U:\BackupLog.txt


:: Outlook file compression and backup
::
::
for %%A in (%USERPROFILE%\Local Settings\Application Data\Microsoft\Outlook) do "C:\Program Files\7-Zip\7z.exe" a -t7z -mx5 "U:\outlooknew" -xr!*.bat "%USERPROFILE%\Local Settings\Application Data\Microsoft\Outlook">>U:\BackupLog.txt
REN "U:\%USERPROFILE%outlook.7z" "outlookold.7z"
REN "U:\outlooknew.7z" "%USERPROFILE%outlook.7z"
DEL "U:\outlooknew.7z"
DEL "U:\outlookold.7z"



::User file compression and backup
::
::
for %%A in (%USERPROFILE%\My Documents\Vitusa) do "C:\Program Files\7-Zip\7z.exe" a -t7z -mx5 "U:\Vitusanew" -xr!*.bat "%USERPROFILE%\My Documents\Vitusa">>U:\BackupLog.txt
REN "U:\%USERPROFILE%Vitusa.7z" "Vitusaold.7z"
REN "U:\Vitusanew.7z" "%USERPROFILE%Vitusa.7z"
DEL "U:\Vitusanew.7z"
DEL "U:\Vitusaold.7z"

Log created upon execution (over 4 hrs! - but the outlook contents are 9GB and seem to compress to 6.5GB during this)
*** I have updated the actual file names with "(file)" - but there is a mix of xls, doc, pdf, jpg etc

ECHO is on.

7-Zip 9.20 Copyright (c) 1999-2010 Igor Pavlov 2010-11-18
Scanning

Creating archive U:\outlooknew.7z

Compressing Outlook\extend.dat
Compressing Outlook\spscoll.dat
Compressing Outlook\Outlook.sharing.xml.obi
Compressing Outlook\~last~.sharing.xml.obi
Compressing Outlook\archive.pst
Compressing Outlook\Archive1.pst
Compressing Outlook\Outlook.pst

Everything is Ok

7-Zip 9.20 Copyright (c) 1999-2010 Igor Pavlov 2010-11-18

Scanning

Updating archive U:\outlooknew.7z

Compressing Outlook\extend.dat
Compressing Outlook\spscoll.dat
Compressing Outlook\Outlook.sharing.xml.obi
Compressing Outlook\~last~.sharing.xml.obi
Compressing Outlook\archive.pst
Compressing Outlook\Archive1.pst
Compressing Outlook\Outlook.pst

Everything is Ok

7-Zip 9.20 Copyright (c) 1999-2010 Igor Pavlov 2010-11-18

Scanning

Updating archive U:\outlooknew.7z

Compressing Outlook\extend.dat
Compressing Outlook\spscoll.dat
Compressing Outlook\Outlook.sharing.xml.obi
Compressing Outlook\~last~.sharing.xml.obi
Compressing Outlook\archive.pst
Compressing Outlook\Archive1.pst
Compressing Outlook\Outlook.pst

Everything is Ok

7-Zip 9.20 Copyright (c) 1999-2010 Igor Pavlov 2010-11-18

Scanning

Updating archive U:\outlooknew.7z

Compressing Outlook\extend.dat
Compressing Outlook\spscoll.dat
Compressing Outlook\Outlook.sharing.xml.obi
Compressing Outlook\~last~.sharing.xml.obi
Compressing Outlook\archive.pst
Compressing Outlook\Archive1.pst
Compressing Outlook\Outlook.pst

Everything is Ok

7-Zip 9.20 Copyright (c) 1999-2010 Igor Pavlov 2010-11-18

Scanning

Updating archive U:\outlooknew.7z

Compressing Outlook\extend.dat
Compressing Outlook\spscoll.dat
Compressing Outlook\Outlook.sharing.xml.obi
Compressing Outlook\~last~.sharing.xml.obi
Compressing Outlook\archive.pst
Compressing Outlook\Archive1.pst
Compressing Outlook\Outlook.pst

Everything is Ok

7-Zip 9.20 Copyright (c) 1999-2010 Igor Pavlov 2010-11-18
Scanning

Creating archive U:\Vitusanew.7z

Compressing Vitusa\Attachment
Compressing Vitusa\(file).jpg
Compressing Vitusa\(file).html
Compressing Vitusa\(file).docx
Compressing Vitusa\(file).docx
Compressing Vitusa\(file).docx
Compressing Vitusa\(file).docx
Compressing Vitusa\(file).docx
Compressing Vitusa\(file).docx
Compressing Vitusa\(file).docx
Compressing Vitusa\(file).docx
Compressing Vitusa\(file)st.docx
Compressing Vitusa\(file).docx
Compressing Vitusa\(file).docx
Compressing Vitusa\(file).docx
Compressing Vitusa\(file).docx
Compressing Vitusa\(file).docx
Compressing Vitusa\(file).docx
Compressing Vitusa\(file).docx
Compressing Vitusa\(file).docx
Compressing Vitusa\(file).xls
Compressing Vitusa\(file).xls
Compressing Vitusa\(file).XLS
Compressing Vitusa\(file).XLS
Compressing Vitusa\(file).pdf
Compressing Vitusa\(file).rdp
Compressing Vitusa\(file).xlsx
Compressing Vitusa\(file).xlsx
Compressing Vitusa\(file).xlsx
Compressing Vitusa\(file).xlsx
Compressing Vitusa\(file).xlsx
Compressing Vitusa\(file).xlsx
Compressing Vitusa\(file).xlsx
Compressing Vitusa\(file).xlsx
Compressing Vitusa\(file).xlsx
Compressing Vitusa\(file).xlsx
Compressing Vitusa\(file).xlsx

Everything is Ok

7-Zip 9.20 Copyright (c) 1999-2010 Igor Pavlov 2010-11-18

Scanning

Updating archive U:\Vitusanew.7z

Compressing Vitusa\Attachment
Compressing Vitusa\(file).jpg
Compressing Vitusa\(file).html
Compressing Vitusa\(file).docx
Compressing Vitusa\(file).docx
Compressing Vitusa\(file).docx
Compressing Vitusa\(file).docx
Compressing Vitusa\(file).docx
Compressing Vitusa\(file).docx
Compressing Vitusa\(file).docx
Compressing Vitusa\(file).docx
Compressing Vitusa\(file)st.docx
Compressing Vitusa\(file).docx
Compressing Vitusa\(file).docx
Compressing Vitusa\(file).docx
Compressing Vitusa\(file).docx
Compressing Vitusa\(file).docx
Compressing Vitusa\(file).docx
Compressing Vitusa\(file).docx
Compressing Vitusa\(file).docx
Compressing Vitusa\(file).xls
Compressing Vitusa\(file).xls
Compressing Vitusa\(file).XLS
Compressing Vitusa\(file).XLS
Compressing Vitusa\(file).pdf
Compressing Vitusa\(file).rdp
Compressing Vitusa\(file).xlsx
Compressing Vitusa\(file).xlsx
Compressing Vitusa\(file).xlsx
Compressing Vitusa\(file).xlsx
Compressing Vitusa\(file).xlsx
Compressing Vitusa\(file).xlsx
Compressing Vitusa\(file).xlsx
Compressing Vitusa\(file).xlsx
Compressing Vitusa\(file).xlsx
Compressing Vitusa\(file).xlsx
Compressing Vitusa\(file).xlsx

Everything is Ok

7-Zip 9.20 Copyright (c) 1999-2010 Igor Pavlov 2010-11-18

Scanning

Updating archive U:\Vitusanew.7z

Compressing Vitusa\Attachment
Compressing Vitusa\(file).jpg
Compressing Vitusa\(file).html
Compressing Vitusa\(file).docx
Compressing Vitusa\(file).docx
Compressing Vitusa\(file).docx
Compressing Vitusa\(file).docx
Compressing Vitusa\(file).docx
Compressing Vitusa\(file).docx
Compressing Vitusa\(file).docx
Compressing Vitusa\(file).docx
Compressing Vitusa\(file)st.docx
Compressing Vitusa\(file).docx
Compressing Vitusa\(file).docx
Compressing Vitusa\(file).docx
Compressing Vitusa\(file).docx
Compressing Vitusa\(file).docx
Compressing Vitusa\(file).docx
Compressing Vitusa\(file).docx
Compressing Vitusa\(file).docx
Compressing Vitusa\(file).xls
Compressing Vitusa\(file).xls
Compressing Vitusa\(file).XLS
Compressing Vitusa\(file).XLS
Compressing Vitusa\(file).pdf
Compressing Vitusa\(file).rdp
Compressing Vitusa\(file).xlsx
Compressing Vitusa\(file).xlsx
Compressing Vitusa\(file).xlsx
Compressing Vitusa\(file).xlsx
Compressing Vitusa\(file).xlsx
Compressing Vitusa\(file).xlsx
Compressing Vitusa\(file).xlsx
Compressing Vitusa\(file).xlsx
Compressing Vitusa\(file).xlsx
Compressing Vitusa\(file).xlsx
Compressing Vitusa\(file).xlsx

Everything is Ok

7-Zip 9.20 Copyright (c) 1999-2010 Igor Pavlov 2010-11-18

Scanning

Updating archive U:\Vitusanew.7z
Compressing Vitusa\Attachment
Compressing Vitusa\(file).jpg
Compressing Vitusa\(file).html
Compressing Vitusa\(file).docx
Compressing Vitusa\(file).docx
Compressing Vitusa\(file).docx
Compressing Vitusa\(file).docx
Compressing Vitusa\(file).docx
Compressing Vitusa\(file).docx
Compressing Vitusa\(file).docx
Compressing Vitusa\(file).docx
Compressing Vitusa\(file)st.docx
Compressing Vitusa\(file).docx
Compressing Vitusa\(file).docx
Compressing Vitusa\(file).docx
Compressing Vitusa\(file).docx
Compressing Vitusa\(file).docx
Compressing Vitusa\(file).docx
Compressing Vitusa\(file).docx
Compressing Vitusa\(file).docx
Compressing Vitusa\(file).xls
Compressing Vitusa\(file).xls
Compressing Vitusa\(file).XLS
Compressing Vitusa\(file).XLS
Compressing Vitusa\(file).pdf
Compressing Vitusa\(file).rdp
Compressing Vitusa\(file).xlsx
Compressing Vitusa\(file).xlsx
Compressing Vitusa\(file).xlsx
Compressing Vitusa\(file).xlsx
Compressing Vitusa\(file).xlsx
Compressing Vitusa\(file).xlsx
Compressing Vitusa\(file).xlsx
Compressing Vitusa\(file).xlsx
Compressing Vitusa\(file).xlsx
Compressing Vitusa\(file).xlsx
Compressing Vitusa\(file).xlsx

Everything is Ok


 

everlost

Honorable
Mar 8, 2013
39
0
10,590
2
looks like your rename syntax is wrong. you may have to copy then rename.

also you can add lines like "date /t >>c:\backuplog.txt" and "time /t >>C:\backuplog.txt" to see what is happening when. to see if its running a command again or just logging it again. the "everything is ok" is just 7zip reporting no errors.

7zip has an update switch/command you could use with your source and compress straight to your destination adding and overwriteing old data as it goes. but i would assume that that will drain your network resources during a backup.

edit - and i still don't know what your %%A is doing, in my tests it returned "unexpected" message. and as a variable, it ran the "do" over and over untill i force stoped. and you seem to be inconsistent in your usage of %userprofile% paths
 

jfk92

Honorable
Jul 10, 2013
3
0
10,510
0


Thanks everlost - for the review/suggestions. I considered the update switch but as you said - was more concerned over jamming up resources. Perhaps I'll add the time/date stamp to further qualify what is happening and when. Puzzling to me that the W7 flavor of this works like a charm for me - just the paths to the 7z executable and the path to outlook and the other folder were altered to reflect XP. Far as the %%A action - I was under the impression that it directed that all files/contents of the path folder would be captured upon execution - but I'm not 100% about that.

Can you explain what you mean by using the %USERPROFILE% variable setting inconsistently - I'm not sure I see that.

thanks for some ideas - I appreciate your time.
 

everlost

Honorable
Mar 8, 2013
39
0
10,590
2
you have instances of "U:\%USERPROFILE%filename.ext", "%USERPROFILE%\filename.ext", and "%USERPROFILE%filename.ext"

where i would expect the commands would be interpereted as
"U:\U:\profiles\users\filename.ext", U:\profiles\users\\filename.ext", and "U:\profiles\users\filename.ext" respectivly. assumeing USERPROFILE="U:\profiles\users\"
 

everlost

Honorable
Mar 8, 2013
39
0
10,590
2
i am haveing a bit of trouble posting today. to continue..

the differences from win7 to winxp could be how the registry stored information (userprofile), added/removed commands or syntax, and/or how variables/flags are handeled (%%A).
 

hang-the-9

Titan
Moderator
You should use %username% in several places where you used %userprofile%

The profile lists the full path to the profile as listed on the computer, the name is just the user's logon name. So U:\Bob for %usename% instead of U:\C:\Users\Bob is what you end up with if you used %userprofile%
 

everlost

Honorable
Mar 8, 2013
39
0
10,590
2
%username% would return just the names. while %userprofile% returns the users profile path. ie: "everlost" vs "c:\documents and settings\everlost"
 
Thread starter Similar threads Forum Replies Date
David___Only Apps General Discussion 0
S Apps General Discussion 4
M Apps General Discussion 3
D Apps General Discussion 2
N Apps General Discussion 1
NoctisLionward Apps General Discussion 2
malavena Apps General Discussion 3
Tom Waller Apps General Discussion 2
P Apps General Discussion 1
S Apps General Discussion 4
A Apps General Discussion 13
Z Apps General Discussion 1
P Apps General Discussion 7
G Apps General Discussion 0
T Apps General Discussion 5
SHADOWSTRIKE1 Apps General Discussion 3
S Apps General Discussion 3
R Apps General Discussion 3
P Apps General Discussion 2
wanamingo Apps General Discussion 1

ASK THE COMMUNITY