Page 1 of 1

Problem with "cmd /k" in a script

Posted: 22 Oct 2023 16:12
by Texano88
I would like to include in my file compression script the possibility of leaving the cmd open at the end of the event with the cmd /k command in the run function

Code: Select all

$zip = "C:\Program Files\7-Zip\7z.exe";
    $sel = quote(get("SelectedItemsPathNames", '" "'));
    $cnt = get("CountSelected");
    if ($cnt > 1) { 
        $zipName = "K:\.compress\" . trim(gpc(<curpath>, "base"), ":", "R") . "_<date yyyy-mm-dd>" . ".7z"; 
    }
    elseif ($cnt == 1) { 
        $zipName = "K:\.compress\" . gpc(<curitem>, "base") . "_<date yyyy-mm-dd>" . ".7z"; 
    }
    else { 
        status "No item(s) selected, aborted!", "8B4513", "stop"; 
        end true;
    }
    $opt = " a -aoa -t7z -m0=lzma2 -mx=9 -mmt8 -mfb=64 -ms=on -bsp1 -bt -bb2 -xr!.bin -xr!.cache -xr!.git -xr!.output -xr!*.log -xr!*.tmp -xr!*.bak";
    run """$zip"" $opt ""$zipName"" $sel";

Code: Select all

 run "cmd /k ""$zip"" $opt ""$zipName"" $sel";
but I get the error: "C:\Program"it is not recognized as an internal or external command,
an executable program or batch file.
How can I enter it correctly so that the terminal stays open?

Re: Problem with "cmd /k" in a script

Posted: 22 Oct 2023 16:29
by highend
No time to look at this atm.

You could instead write a temp .bat file with your 7z command

that ends with a

Code: Select all

ECHO. & ECHO Press any key to continue... & PAUSE >NUL
and run that instead... xD