Zip file with password generated by JavaScript does not have a password

Asked 2 years ago, Updated 2 years ago, 328 views

environment
Client OS: Windows 10 Pro (1809)
Browser IE11

Question

After embedding JavaScript in an HTML file and using ActiveXObject to create a zip file with a password file with 7 zip from the following commands, we are performing the process of deleting the original text file.

·Source image
*Double quotation is an image, so it's a tekito.

varcmd="cmd/c C:\Program Files\7-Zip\7z.exe a-pPassword compress.zip fileA";
wsh.Exec(cmd);
fso.DeleteFile(fileA, true);

At this time, the completed zip file does not have a password.
However, when I forgot to erase the original text file, I had no problem.
As soon as I implemented the process of deleting the original text file, I lost my password.

Could you tell me the cause and how to deal with it?
Thank you in advance.

javascript command-prompt

2022-09-30 22:03

1 Answers

Exec() runs the following statement without waiting for the command to end, so deleting the target file immediately after Exec() will not successfully create a zip.

Exec() can wait for the command to end in the official document.Also, Run() has a flag waiting for the command to end

.
varoExec=WshShell.Exec("calc");

while(oExec.Status==0)
{
     WScript.Sleep(100);
}

WScript.Echo(oExec.Status);


2022-09-30 22:03

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.