Abyssmedia.com Forum Index Abyssmedia.com
Abyssmedia Support Forums
 
  FAQ    Search    Memberlist    Usergroups   Register 
  Profile    Log in to check your private messages    Log in 

include function - How to...

 
Post new topic   Reply to topic    Abyssmedia.com Forum Index -> Quick Batch File Compiler
View previous topic :: View next topic  
Author Message
fairlane76



Joined: 11 Aug 2005
Posts: 3

PostPosted: Thu Aug 11, 2005 11:15 am    Post subject: Reply with quote

Hi,

How does one use the include facility?

I have made a backup solution in a .bat file which compresses a whole directory. So far I've had the compression utility on c:\7z\7z.exe
I have tried to call the included 7z.exe with the following commands without success:

7z.exe
CALL 7z.exe
CALL %systemdrive%\7z.exe
CALL %system%7z.exe

So, what is the path to a file included in the generated batch.exe?

Thanks.

FF
Back to top
sixpack



Joined: 08 Dec 2004
Posts: 13

PostPosted: Thu Aug 11, 2005 10:41 pm    Post subject: Reply with quote

first of all your directory is c:\7z\7z.exe
so wy try to:
CALL 7z.exe
CALL %systemdrive%\7z.exe
CALL %system%7z.exe ???

it's %systemdrive%\7z\7z.exe

or

Code:

@echo off
cd
7z.exe

if the batch file is in the same directory as the 7z.exe

note: to use 7z in a batch file use the
7za.exe
(standalone console version) not the 7z.exe

second
if you want to zip up a directory with 7z you MUST use swithes for 7z

Examples

Code:
7z a -tzip archive.zip subdir\*

adds all files from directory subdir to archive archive.zip.

7z a -tzip Files.zip "Program files\*" -r

adds all files from directory Program to archive Files.zip


read more in the 7z help file

this is a backup batch file snipped that is use my self.
i use winrar instead of 7z but you get the idea (i hope)

Quote:
if not exist "%USERPROFILE%\Application Data\Thunderbird" goto runa
echo ### Backup Maken van Mozilla thunderbird (Instellingen)...
if not exist "%drive%\Backup\Thunderbird" mkdir "%drive%\Backup\Thunderbird"
%backupcmd% "%USERPROFILE%\Application Data\Thunderbird" "%drive%\Backup\Thunderbird"
"%systemdrive%\Backup Diz\rar\WinRAR.exe" a -sfx -zThunderbird.diz -rr1%% -u -ed -ep1 -r -os -av -m4 "%drive%\Backup\Thunderbird" "%drive%\Backup\Thunderbird"
ECHO * Mozilla Thunderbird (Instellingen) >>%txt%
ECHO ---------------------------------- >>%txt%
dir "%USERPROFILE%\Application Data\Thunderbird" /s /b /-p /o:gn >>%txt%
ECHO. >>%txt%
ECHO.
ECHO.
ECHO.
:runa
if not exist "%programfiles%\Opera" goto run
echo ### Backup Maken van Opera Web Browser (Instellingen)...
if not exist "%drive%\Backup\Opera" mkdir "%drive%\Backup\Opera"
%backupcmd% "%programfiles%\Opera\Mail" "%drive%\Backup\Opera\Mail"
%backupcmd% "%programfiles%\Opera\profile" "%drive%\Backup\Opera\profile"
"%systemdrive%\Backup Diz\rar\WinRAR.exe" a -sfx -zOpera_mail.diz -rr1%% -u -ed -ep1 -r -os -av -m4 "%drive%\Backup\Opera\Mail" "%drive%\Backup\Opera\Mail"
"%systemdrive%\Backup Diz\rar\WinRAR.exe" a -sfx -zOpera_Profile.diz -rr1%% -u -ed -ep1 -r -os -av -m4 "%drive%\Backup\Opera\profile" "%drive%\Backup\Opera\profile"
if exist "%drive%\Backup\Opera\Mail.exe" ren "%drive%\Backup\Opera\Mail.exe" "Opera_Mail.exe"
if exist "%drive%\Backup\Opera\profile.exe" ren "%drive%\Backup\Opera\profile.exe" "Opera_Profile.exe"
ECHO * Opera Web Browser (Instellingen) >>%txt%
ECHO -------------------------------- >>%txt%
dir "%programfiles%\Opera\Mail" /s /b /-p /o:gn >>%txt%
dir "%programfiles%\Opera\profile" /s /b /-p /o:gn >>%txt%
ECHO. >>%txt%
ECHO.
ECHO.
ECHO.
:run
if not exist "%USERPROFILE%\Application Data\Mozilla" goto run0
echo ### Backup Maken van Mozilla Firefox (Instellingen)...
if not exist "%drive%\Backup\Mozilla" mkdir "%drive%\Backup\Mozilla"
%backupcmd% "%USERPROFILE%\Application Data\Mozilla" "%drive%\Backup\Mozilla"
"%systemdrive%\Backup Diz\rar\WinRAR.exe" a -sfx -zFirefox.diz -rr1%% -u -ed -ep1 -r -os -av -m4 "%drive%\Backup\Mozilla" "%drive%\Backup\Mozilla"
if exist "%drive%\Backup\Mozilla.exe" ren "%drive%\Backup\Mozilla.exe" "Mozilla_Firefox.exe"
ECHO * Mozilla Firefox (Instellingen) >>%txt%
ECHO ----------------------------- >>%txt%
dir "%USERPROFILE%\Application Data\Mozilla" /s /b /-p /o:gn >>%txt%
ECHO. >>%txt%
ECHO.
ECHO.
ECHO.


variables you can use
Quote:
%CD% - Returns the current directory string.
%CMDCMDLINE% - Returns the exact command line used to start the current Cmd.exe.
%CMDEXTVERSION% - Returns the version number of the current Command Processor Extensions.
%COMSPEC% - Returns the exact path to the command shell executable.
%ERRORLEVEL% - Returns the error code of the most recently used command. A non zero value usually indicates an error.
%HOMEDRIVE% - Returns which local workstation drive letter is connected to the user's home directory.
%HOMEPATH% - Returns the full path of the user's home directory.
%HOMESHARE% - Returns the network path to the user's shared home directory.
%LOGONSEVER% - Returns the name of the domain controller that validated the current logon session.
%NUMBER_OF_PROCESSORS% - Specifies the number of processors installed on the computer.
%OS% - Returns the operating system name.
%PATH% - Specifies the search path for executable files.
%PATHEXT% - Returns a list of the file extensions that the operating system considers to be executable.
%PROCESSOR_ARCHITECTURE% - Returns the chip architecture of the processor. Values: x86, IA64.
%PROCESSOR_IDENTIFIER% - Returns a description of the processor.
%PROCESSOR_LEVEL% - Returns the model number of the processor installed on the computer.
%PROCESSOR_REVISION% - Returns the revision number of the processor.
%PROMPT% - Returns the command prompt settings for the current interpreter. Generated by Cmd.exe.
%RANDOM% - Returns a random decimal number between 0 and 32767. Generated by Cmd.exe.
%TEMP% - Returns the default temporary directories that are used by applications available to users who are currently logged on.
%TMP% - Some applications require TEMP and others require TMP.
%TIME% - Returns the current time.
%date% - returns the current date.
%USERDOMAIN% Returns the name of the domain that contains the user's account.
%WINDIR% Returns the location of the operating system directory.
%sysdir% - normally 'C:\WINDOWS\System32
%allusersprofile% - path to the all users profile directory
%userprofile% - path to the user profile directory
%commonprogramfiles% - path to common program files directory
%systemdrive% - normally 'C:\'
%windir% - normally 'C:\WINDOWS'
%programfiles% - normally 'C:\Programme Files
%userprofile% = C:\documents and settings\FRED (Fred is the current user logged on)
%AllUsersProfile% = C:\documents and settings\All Users
%USERNAME% = naam van de huidige gebruiker
%computername% = de computer naam


hope this helps you Smile



Edited By sixpack on 1123803131
Back to top
fairlane76



Joined: 11 Aug 2005
Posts: 3

PostPosted: Fri Aug 12, 2005 8:27 am    Post subject: Reply with quote

Wow... Thanks for your very ellaborate answer. I especially find your listing of variables very useful.

About 7z. I am in fact using the 7za.exe and a whole lotta of parameters. But I guess I was too vague on my need.

Lets pretend that 7za.exe does not exist on my users computer. What I want is to include 7za.exe with the batch file, so that the user doesn't have to have the program anywhere on the computer. IE like a stand-alone application, an exe that includes both the batch file as well as the 7za.exe file.

The line I use to call 7za.exe is:
CALL 7za.exe a c:\temp\backup\data%date%.7z -r c:\data\*
But this doesn't work because the batch file doesn't recognize where the 7za.exe file is.
After this I simply open a network connection to my server and move the backup%date%.7z to the network share.

Any ideas on where the file is when its included in the batch.exe?

Thanks.

Kim

For anyone interested heres my backup procedure. When I get it to work I will include mail directories as well as bookmarks of both iexplorer and firefox.

@ECHO OFF
title Company Name - BACKUP @ %date%
REM ************************************************************
REM THIS BACKUP PROCEDURE HAS LAST BEEN REVISED 08AUG2005 BY Kim
REM ************************************************************
CLS
ECHO.
ECHO YOU HAVE STARTED THE BACKUP PROCEDURE
ECHO.
ECHO THIS PROCEDURE MIGHT TAKE A LITTLE WHILE
ECHO DEPENDING ON THE AMOUNT OF DATA YOU HAVE.
ECHO.
ECHO.
ECHO TO CANCEL THE OPERATION PRESS Ctrl+C
ECHO OR CLICK ON THE X IN THE CORNER OF THIS WINDOW
ECHO.
ECHO OR...
PAUSE
CLS
PING 192.168.0.2 FIND "Reply from " > NUL
IF ERRORLEVEL 1 GOTO check
IF ERRORLEVEL 0 GOTO offline

:check
NET USE V: \\server1\username password /USER:server1\username /PERSISTENT:NO > NUL
IF EXIST "v:\data%date%.7z" GOTO fileexists ELSE GOTO continue

:continue
CLS
ECHO.
ECHO BACKUP PROCEDURE IN PROGRESS...
ECHO.
ECHO PLEASE WAIT......
ECHO.

REM Compressing Files
echo.
echo Compressing your data
CALL 7za.exe a c:\temp\backup\data%date%.7z -r c:\data\* > NUL

REM Move The File
echo.
echo Copying data to network
move C:\temp\backup\*.7z v:\ > NUL

REM Close The Network Share
NET USE v: /delete > NUL

CLS
echo.
echo BACKUP PROCEDURE COMPLETE.
echo.
echo THANK YOU FOR YOUR PATIENCE!
echo.
echo.
echo *** REMEMBER TO SAVE YOUR FILES ATLEAST ONCE A WEEK ***
echo.
echo.
pause
exit

:offline
echo.
echo You are not connected to the network.
echo Please connect your computer to the network and try again.
echo.
echo If you are connected and still recieve this message, please
echo call your network administrator or send an email to admin@network.com
echo.
pause
exit

:fileexists
net use V: /delete > NUL
echo.
echo You have already performed backup today.
echo Have a nice day!
echo.
echo If this is an error, please call your network administrator
echo or send an email to admin@network.com
echo.
pause
exit
Back to top
Oleg Tsheglov
Site Admin


Joined: 13 Feb 2004
Posts: 309

PostPosted: Sat Aug 13, 2005 2:24 am    Post subject: Reply with quote

You can download latest beta from http://www.abyssmedia.com/downloads/qbfc-beta.exe
and use %MYFILES% variable to get path to included files.
for example @call %MYFILES%/7za.exe
Back to top
sixpack



Joined: 08 Dec 2004
Posts: 13

PostPosted: Sat Aug 13, 2005 11:56 am    Post subject: Reply with quote

@fairlane76

try to use
Code:

cd
7za.exe a c:\temp\backup\data%date%.7z -r c:\data\*




@Oleg Tsheglov
thanks for the beta



Edited By sixpack on 1123934196
Back to top
fairlane76



Joined: 11 Aug 2005
Posts: 3

PostPosted: Mon Aug 15, 2005 7:17 am    Post subject: Reply with quote

@Oleg

Thanks for the beta. It works like a charm.


@six

Thanks for your input. Didn't need to try your latest trick since Oleg gaves us a beta that works. Nevertheless, thank you for your help.

Best regards to both of you,
Kim
Back to top
sixpack



Joined: 08 Dec 2004
Posts: 13

PostPosted: Mon Aug 15, 2005 1:54 pm    Post subject: Reply with quote

any time
Back to top
thickfreakness



Joined: 21 Apr 2005
Posts: 14

PostPosted: Sun Sep 04, 2005 11:03 pm    Post subject: Reply with quote

Oleg Tsheglov wrote:
You can download latest beta from http://www.abyssmedia.com/downloads/qbfc-beta.exe
and use %MYFILES% variable to get path to included files.
for example @call %MYFILES%/7za.exe

so included files now go to the "Application Data" folder?

anyway to make them go in the same folder as the compiled EXE?
Back to top
Oleg Tsheglov
Site Admin


Joined: 13 Feb 2004
Posts: 309

PostPosted: Mon Sep 05, 2005 1:18 pm    Post subject: Reply with quote

Yes, this guarantee that files will be decompressed (recommended by Microsoft).
When you decompress files to same folder as EXE:
1. You may not have permissions to write this folder under WinXP/2000/2003
2. EXE file runned from CD-ROM....

Ok. I can add this option to compiler: decompress to current folder/AppData folder/Temp folder....
Back to top
thickfreakness



Joined: 21 Apr 2005
Posts: 14

PostPosted: Mon Sep 05, 2005 10:37 pm    Post subject: Reply with quote

Oleg Tsheglov wrote:
Yes, this guarantee that files will be decompressed (recommended by Microsoft).
When you decompress files to same folder as EXE:
1. You may not have permissions to write this folder under WinXP/2000/2003
2. EXE file runned from CD-ROM....

Ok. I can add this option to compiler: decompress to current folder/AppData folder/Temp folder....

that would be great
Back to top
daver



Joined: 08 Sep 2005
Posts: 1

PostPosted: Thu Sep 08, 2005 11:20 am    Post subject: Reply with quote

Oleg Tsheglov wrote:
Ok. I can add this option to compiler: decompress to current folder/AppData folder/Temp folder....

Ok, I'm confused.

I just tried the include function. I used %MYFILES% in the call path to all included files. But the files were extracted to the folder the application was run from.

I changed the call paths back to the original paths, compiled and ran my test app again. This time it still decompressed the included files to current directory, but they were now all 0KB.

Dave



Edited By daver on 1126178578
Back to top
Oleg Tsheglov
Site Admin


Joined: 13 Feb 2004
Posts: 309

PostPosted: Thu Sep 08, 2005 10:11 pm    Post subject: Reply with quote

Daver,
%MYFILES% supported only in latest beta-version http://www.abyssmedia.com/downloads/qbfc-beta.exe
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Abyssmedia.com Forum Index -> Quick Batch File Compiler All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001-2011 phpBB Group