I would like to create a script to add a path to the Windows System Path variable.

I searched a lot and found some possible solutions, but I'm afraid of making a mistake since I've heard reports that some commands can corrupt the local Path variable and then prevent the computer from booting again.

I would like to include via .bat the path C:\Scripts in the variable Path of the system.

What is the best way to do this?

  • 1
    What have you tried?
    – Ramhound
    Oct 26, 2022 at 14:46
  • That's the thing, I didn't try anything because I was afraid of corrupting something... I was going to try this: setx path "%path%;C:\Scripts" /m or this REG ADD HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\ Control\Session Manager\Environment /v Path /t REG_SZ /d C:\Scripts /f Oct 26, 2022 at 15:14
  • 1
    Microsoft provides free (as in air) Windows developer VM(s) that support all major hypervisors. Great way to test things you are worried about.
    – Ramhound
    Oct 26, 2022 at 20:50
  • Does this answer your question? Setting or modifying a (system wide) environment variable in cmd.exe Oct 28, 2022 at 4:26

1 Answer 1


You're in the right direction, but it seems that your problem is really the fear of making mistakes.

setx is much safer than updating the registry, so is the way to go.

If you're worried about making mistakes, create a System Restore point, so that you could always rollback to your current state.

Reference : How to use System Restore on Windows 10.

  • @TyroneHirt - You might test your ability to actually roll back to a restoration point before you trust it to work.
    – Ramhound
    Oct 26, 2022 at 20:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .