this post was submitted on 10 Apr 2024
114 points (87.0% liked)

Technology

59569 readers
3431 users here now

This is a most excellent place for technology news and articles.


Our Rules


  1. Follow the lemmy.world rules.
  2. Only tech related content.
  3. Be excellent to each another!
  4. Mod approved content bots can post up to 10 articles per day.
  5. Threads asking for personal tech support may be deleted.
  6. Politics threads may be removed.
  7. No memes allowed as posts, OK to post as comments.
  8. Only approved bots from the list below, to ask if your bot can be added please contact us.
  9. Check for duplicates before posting, duplicates may be removed

Approved Bots


founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[–] Blue_Morpho@lemmy.world 1 points 7 months ago (1 children)

It's really difficult to write logic that will correctly escape any argument given to it, cmd.exe really is a pain to deal with :/

Is cmd.exe even a thing in Windows? I know it exists and you can run it but I thought I read that the default is Power Shell now. (Just Googled, yeah Powershell replaced cmd.exe by default in 2022.)

[–] wkk@lemmy.world 1 points 7 months ago* (last edited 7 months ago) (1 children)

https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-createprocessa

To run a batch file, you must start the command interpreter; set lpApplicationName to cmd.exe and set lpCommandLine to the following arguments: /c plus the name of the batch file.

Because a batch file (.bat or .cmd) is basically a set of cmd.exe instructions I guess that's why you can't get away from it.

And as if making sense of this CreateProcessA system call wasn't funny enough, you also need to figure out how to safely prepare that lpCommandLine for it following all of cmd.exe's weird escaping rules... lol

[–] Blue_Morpho@lemmy.world 2 points 7 months ago (1 children)

Do you have to run a batch file? Why not a Powershell script since that's the default?

[–] wkk@lemmy.world 2 points 7 months ago

If you can avoid running batch files altogether then great, amazing. But there are projects out there using Rust that still depend on running those and that's the focus of the issue... But yeah I cannot wait until the day I won't hear about cmd.exe again.