M
M
Michael Compass2021-07-14 10:26:27
JavaScript
Michael Compass, 2021-07-14 10:26:27

How to run cmd code in JS without first creating the cmd file itself?

I start the cmd.exe process in js like this:

native_async("processmanager", "start", JSON.stringify({location: "cmd.exe", working_folder: "", waitfinish: true, arguments: "", version: 2}))!

I can’t understand how to run this batch code in the code that I wrote above:
@for /f %%i in ('set /a 1^^^<^^^<10') do @for %%j in ("C:\Users\username\Downloads\test5\yd\*.txt") do @if %%~zj leq %%i del "%%j"

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
res2001, 2021-07-14
@mik777em

Pass the command as parameters to cmd. On the command line, it would look something like this:

cmd.exe /C @for /f %i in ('set /a 1^^^<^^^<10') do @for %j in ("C:\Users\username\Downloads\test5\yd\*.txt") do @if %~zj leq %i del "%j"

Please note that the loop variables from the command line must be accessed through 1 percent sign, and not through 2 as in the batch file.
PS: I didn’t understand what kind of constructions you built in set. In my opinion it doesn't work. And I have no idea what she should do. And you?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question