Page 1 of 1

7zip command line hide

Posted: 24 Mar 2017, 23:52
by ellie59
Hi all, :wave:

This command I use in "X.bat" for backup and works well

Code: Select all

cd ./7zip
7za -t7z a "C:\Users\Windows\Desktop\B\[%DATE:~3,2%.%DATE:~6,2%.%DATE:~9,4%]-[%TIME:~0,2%.%TIME:~3,2%.%TIME:~6,2%] Backup.7z" -mx=9 -ssw "C:\Users\Windows\Desktop\A\*" -x@"..\exceptions.conf" -r
I want convert this command to "X.ahk" + Hide command line when 7zip running archiving
I tried %COMSPEC% but still I am doing something wrong :headwall:

Re: 7zip command line hide

Posted: 25 Mar 2017, 00:13
by tmplinshi
The % and , should be escaped, for example:

Code: Select all

Run, cmd /k echo `%date:~1`,2`%
Or:

Code: Select all

var =
(%
%COMSPEC% /c 7za -t7z a "C:\Users\Windows\Desktop\B\[%DATE:~3,2%.%DATE:~6,2%.%DATE:~9,4%]-[%TIME:~0,2%.%TIME:~3,2%.%TIME:~6,2%] Backup.7z" -mx=9 -ssw "C:\Users\Windows\Desktop\A\*" -x@"..\exceptions.conf" -r
)
Run, %var%, ./7zip, Hide

Re: 7zip command line hide

Posted: 25 Mar 2017, 06:23
by ellie59
It does not work :shock:

Error: "Failed attempt to launch program or document"

you can try it in person:
http://www.7-zip.org/a/7z1604-extra.7z

Example (shortened version for testing):

Code: Select all

cd ./7zip
7za -t7z a "C:\Users\Name\Desktop\B\Test.7z" -mx=9 -ssw "C:\Users\Name\Desktop\A\*" -r

Re: 7zip command line hide

Posted: 25 Mar 2017, 07:35
by tmplinshi

Code: Select all

var =
(%
%COMSPEC% /c 7za -t7z a "C:\Users\Name\Desktop\B\Test.7z" -mx=9 -ssw "C:\Users\Name\Desktop\A\*" -r
)
Run, %var%, ./7zip, Hide
Works for me. Make sure the script and 7zip folder is in the same path. Or specify the fullpath to 7za.exe:

Code: Select all

var =
(%
%COMSPEC% /c "d:\path to\7zip\7za.exe" -t7z a "C:\Users\Name\Desktop\B\Test.7z" -mx=9 -ssw "C:\Users\Name\Desktop\A\*" -r
)
Run, %var%,, Hide

Re: 7zip command line hide

Posted: 27 Mar 2017, 21:29
by ellie59
it still shows error :headwall:
https://ctrlv.cz/shots/2017/03/28/TT0o.png

C:\Users\Windows\Desktop\7zip
C:\Users\Windows\Desktop\7zip\A
C:\Users\Windows\Desktop\7zip\B

Code: Select all

var =
(%
%COMSPEC% /c "C:\Users\Windows\Desktop\7zip\7za.exe" -t7z a "C:\Users\Windows\Desktop\7zip\B\Test.7z" -mx=9 -ssw "C:\Users\Windows\Desktop\7zip\A\*" -r
)
Run, %var%,, Hide
What am I doing wrong?

Re: 7zip command line hide

Posted: 27 Mar 2017, 22:09
by AlleyArtwork
can you try something like

Code: Select all

runwait, C:\Program Files\7-Zip\7z.exe a -tzip ZipFileName.zip \\location\ofstuff\tozip\, \\placeto\putzips\, Hide
I use something with a GUI front end to archive P drive data for terminated users after inputting user name(s), then delete the original P drives after they're archived. This hides the CMD window.

reference command line commands: https://sevenzip.osdn.jp/chm/cmdline/commands/index.htm

Re: 7zip command line hide

Posted: 27 Mar 2017, 22:52
by tmplinshi
ellie59 wrote:it still shows error :headwall:
https://ctrlv.cz/shots/2017/03/28/TT0o.png

C:\Users\Windows\Desktop\7zip
C:\Users\Windows\Desktop\7zip\A
C:\Users\Windows\Desktop\7zip\B

Code: Select all

var =
(%
%COMSPEC% /c "C:\Users\Windows\Desktop\7zip\7za.exe" -t7z a "C:\Users\Windows\Desktop\7zip\B\Test.7z" -mx=9 -ssw "C:\Users\Windows\Desktop\7zip\A\*" -r
)
Run, %var%,, Hide
What am I doing wrong?
Oh, I'm sorry, my mistake, I was using cmd /c to test. Try again with:

Code: Select all

var =
(%
"C:\Users\Windows\Desktop\7zip\7za.exe" -t7z a "C:\Users\Windows\Desktop\7zip\B\Test.7z" -mx=9 -ssw "C:\Users\Windows\Desktop\7zip\A\*" -r
)
Run, %COMSPEC% /c %var%,, Hide
or:

Code: Select all

var =
(%
cmd /c "C:\Users\Windows\Desktop\7zip\7za.exe" -t7z a "C:\Users\Windows\Desktop\7zip\B\Test.7z" -mx=9 -ssw "C:\Users\Windows\Desktop\7zip\A\*" -r
)
Run, %var%,, Hide

Re: 7zip command line hide

Posted: 28 Mar 2017, 00:47
by BoBo
I'd guess that any part of that string/statement needs to be enclosed in quotation marks - means even the cmd shell parameters, right?

Please check out how variables are treated within an expression.
(% %COMSPEC% " /k ...
vs.
(% COMSPEC " /k ...

Re: 7zip command line hide

Posted: 28 Mar 2017, 13:22
by ellie59
Ok, recap :crazy:

Bat script that I want to convert to the "AHK" file + hide the notification window during compression...
(.bat script is working)

Code: Select all

cd ./7zip
7za -t7z a "C:\Users\Windows\Desktop\TESTSCRIPT\B\[%DATE:~3,2%.%DATE:~6,2%.%DATE:~9,4%]-[%TIME:~0,2%.%TIME:~3,2%.%TIME:~6,2%] Backup.7z" -mx=9 -ssw "C:\Users\Windows\Desktop\TESTSCRIPT\A\*" -x@"..\exceptions.conf" -r
paths:
"C:\Users\Windows\Desktop\TESTSCRIPT"
"C:\Users\Windows\Desktop\TESTSCRIPT\7zip" = "cd ./7zip"
"C:\Users\Windows\Desktop\TESTSCRIPT\A"
"C:\Users\Windows\Desktop\TESTSCRIPT\B"

Abridged versions for testing (.bat script is working)

Code: Select all

start /d "C:\Users\Windows\Desktop\TESTSCRIPT\7zip\" 7za -t7z a "C:\Users\Windows\Desktop\TESTSCRIPT\B\Backup.7z" -mx=9 -ssw "C:\Users\Windows\Desktop\TESTSCRIPT\A\*" -r
(AHK script is working)

Code: Select all

run, %COMSPEC% /c start /d "C:\Users\Windows\Desktop\TESTSCRIPT\7zip\" 7za -t7z a "C:\Users\Windows\Desktop\TESTSCRIPT\B\Backup.7z" -mx=9 -ssw "C:\Users\Windows\Desktop\TESTSCRIPT\A\*" -r
(AHK script is working)

Code: Select all

var =
(%
start /d "C:\Users\Windows\Desktop\TESTSCRIPT\7zip\" 7za -t7z a "C:\Users\Windows\Desktop\TESTSCRIPT\B\Backup.7z" -mx=9 -ssw "C:\Users\Windows\Desktop\TESTSCRIPT\A\*" -r
)
Run, %COMSPEC% /c %var%
tmplinshi: (AHK-1 script is not working)

Code: Select all

var =
(%
"C:\Users\Windows\Desktop\TESTSCRIPT\7zip\7za.exe" -t7z a "C:\Users\Windows\Desktop\TESTSCRIPT\B\Backup.7z" -mx=9 -ssw "C:\Users\Windows\Desktop\TESTSCRIPT\A\*" -r
)
Run, %COMSPEC% /c %var%,, Hide
tmplinshi: (AHK-2 script is not working)

Code: Select all

var =
(%
cmd /c "C:\Users\Windows\Desktop\TESTSCRIPT\7zip\7za.exe" -t7z a "C:\Users\Windows\Desktop\TESTSCRIPT\B\Backup.7z" -mx=9 -ssw "C:\Users\Windows\Desktop\TESTSCRIPT\A\*" -r
)
Run, %var%,, Hide

-----------------------------------
This version looks like the best solution for me (Unfortunately, hiding does not work)

Code: Select all

var =
(%
start /d "C:\Users\Windows\Desktop\TESTSCRIPT\7zip\" 7za -t7z a "C:\Users\Windows\Desktop\TESTSCRIPT\B\Backup.7z" -mx=9 -ssw "C:\Users\Windows\Desktop\TESTSCRIPT\A\*" -r
)
Run, %COMSPEC% /c %var%,, Hide
If I'm right and ",, Hide" it is only functional within a command line (7za.exe It is a standalone program) and command "Hide" will not affect


Any other ideas? :beer: :eh:

Re: 7zip command line hide

Posted: 28 Mar 2017, 14:19
by BoBo
If I'm right and ",, Hide" it is only functional within a command line (7za.exe It is a standalone program) and command "Hide" will not affect
So why not use "7z.exe" (needs only the additional 7z.dll from the 7zip package) instead of "7za.exe" ?

That should work in hidden mode finally (not tested, and currently set to use /K(iosk mode)).

Code: Select all

7zcl = C:\Users\Windows\Desktop\TESTSCRIPT\7zip\7za.exe -t7z a C:\Users\Windows\Desktop\TESTSCRIPT\B\Backup.7z -mx=9 -ssw C:\Users\Windows\Desktop\TESTSCRIPT\A\* -r
Run, % COMSPEC "/K " . 7zcl ,, Hide

Re: 7zip command line hide

Posted: 28 Mar 2017, 22:48
by tmplinshi

Code: Select all

7zcl =
(%
7za -t7z a "C:\Users\Windows\Desktop\TESTSCRIPT\B\Backup.7z" -mx=9 -ssw "C:\Users\Windows\Desktop\TESTSCRIPT\A\*" -r
)
Run, %COMSPEC% /c %7zcl%, C:\Users\Windows\Desktop\TESTSCRIPT\7zip\, Hide

Re: 7zip command line hide

Posted: 29 Mar 2017, 08:23
by Guest
ellie59 wrote:Hi all, :wave:

This command I use in "X.bat" for backup and works well

Code: Select all

cd ./7zip
7za -t7z a "C:\Users\Windows\Desktop\B\[%DATE:~3,2%.%DATE:~6,2%.%DATE:~9,4%]-[%TIME:~0,2%.%TIME:~3,2%.%TIME:~6,2%] Backup.7z" -mx=9 -ssw "C:\Users\Windows\Desktop\A\*" -x@"..\exceptions.conf" -r
I want convert this command to "X.ahk" + Hide command line when 7zip running archiving
I tried %COMSPEC% but still I am doing something wrong :headwall:

Code: Select all

7z_Path  := "C:\Program Files\7-Zip\7z.exe"
Out_File := "C:\Users\Windows\Desktop\B\[%DATE:~3,2%.%DATE:~6,2%.%DATE:~9,4%]-[%TIME:~0,2%.%TIME:~3,2%.%TIME:~6,2%] Backup.7z"
In_Path  := "C:\Users\Windows\Desktop\A\*"
In_Exc   := "..\exceptions.conf"

If ( FileExist(7z_Path) )
	Run, % """" 7z_Path """ a -t7z """ Out_File """ -mx=9 -ssw """ In_Path """ -x@""" In_Exc """ -r",, Hide

Re: 7zip command line hide

Posted: 29 Mar 2017, 08:59
by Guest
ellie59 wrote:

Code: Select all

cd ./7zip
7za -t7z a "C:\Users\Windows\Desktop\B\[%DATE:~3,2%.%DATE:~6,2%.%DATE:~9,4%]-[%TIME:~0,2%.%TIME:~3,2%.%TIME:~6,2%] Backup.7z" -mx=9 -ssw "C:\Users\Windows\Desktop\A\*" -x@"..\exceptions.conf" -r
*

Code: Select all

7z_Path  := A_ProgramFiles "\7-Zip\7z.exe"
Out_File := A_Desktop "\B\[" A_YYYY "." A_MM "." A_DD "]-[" A_Hour "." A_Min "." A_Sec "] Backup.7z"
In_Path  := A_Desktop "\A\*"
In_Exc   := "..\exceptions.conf"

If ( FileExist(7z_Path) )
	Run, % """" 7z_Path """ a -t7z """ Out_File """ -mx=9 -ssw """ In_Path """ -x@""" In_Exc """ -r",, Hide

Re: 7zip command line hide

Posted: 30 Mar 2017, 19:50
by ellie59
Thank you all! (Work!)

Eventually won tmplinshi and Guest and BoBo :salute: :lol:

Code: Select all

7zcl =
(%
7za -t7z a "C:\Users\Windows\Desktop\TESTSCRIPT\B\Backup.7z" -mx=9 -ssw "C:\Users\Windows\Desktop\TESTSCRIPT\A\*" -r
)
Run, %COMSPEC% /c %7zcl%, C:\Users\Windows\Desktop\TESTSCRIPT\7zip\, Hide

Code: Select all

7z_Path  := "C:\Users\Windows\Desktop\TESTSCRIPT\7zip\7za.exe"
Out_File := "C:\Users\Windows\Desktop\TESTSCRIPT\B\Backup.7z"
In_Path  := "C:\Users\Windows\Desktop\TESTSCRIPT\A\*"
In_Exc   := "C:\Users\Windows\Desktop\TESTSCRIPT\exceptions.conf"

If ( FileExist(7z_Path) )
	Run, % """" 7z_Path """ a -t7z """ Out_File """ -mx=9 -ssw """ In_Path """ -x@""" In_Exc """ -r",, Hide
PS BoBo:
Work with the DLL is the right solution (But I've never worked with it) If you have time and mood, can you give me some examples :angel: