Problem with "cmd /k" in a script

Discuss and share scripts and script files...
Post Reply
d.romeo
Posts: 34
Joined: 08 Oct 2021 23:22

Problem with "cmd /k" in a script

Post by d.romeo »

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?

highend
Posts: 13033
Joined: 06 Feb 2011 00:33

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

Post 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
One of my scripts helped you out? Please donate via Paypal or paypal_donate (at) stdmail (dot) de

Post Reply