Scripting in Windows

24年 10月 2日 Wednesday
246 words
2 minutes

Background story

Recently, I have playing around with Windows scripting to perform automation of installation process.

Fun fact

I haven't do any scripting before in Windows platform, and this is the first I've tried.

So, what's different between linux and windows in terms of scripting?

  1. backslash in the path, WTF?
  2. msiexec need the installer's absolute, full path in order to work, WTF?
  3. escape character is ^ instead of \, WTF?
  4. runas instead of sudo, it require user to interact with a button by clicking it instead of enter some password, WTF?
  5. you can't escalate privilege on current terminal session legally and officially. you must spawn new terminal in order to achieve that. WTF?
  6. beware of error in your bat or cmd script! sometimes it gives you vague error and at the end you realize it just a typo or smth.
  7. why I need to escape any parenthesis inside if block? WTF?

Yeah, that's new to me.

another Windows quirks

  1. in CMD shell, you must use double quote for path that contain spaces, single quote won't work! try this: dir 'C:\Program Files\Tailscale\'
  2. when SSH to your Windows machine and enter msys2 shell, and frustating why /accepteula not working when it should, remember this: MSYS2_ENV_CONV_EXCL
  3. when things don't work the way you expect in msexec, try enable verbose log: /l*v .\installer.log and dump the log to the AI and let 'em figure out the problem! grok tell me the problem is just wrong path.
  4. %temp% folder isn't really temporary, it will be there forever until some program or user itself decided to delete it, lol.

Title:Scripting in Windows

Author:ReYuki

Link:https://www.reyuki.site/posts/scripting-in-windows [copy]

Last updated:


This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. You are free to share and adapt it, as long as you give appropriate credit, don’t use it for commercial purposes, and distribute your contributions under the same license. Provided under license CC BY-NC-SA 4.0