windowsbatch-filecmdexenative-executable

Can we change "Windows native commands" default system directory location


I want to get the windows system directory(i,e C:\Windows\System32) where windows native files(like cmd.exe, xcopy.exe, reg.exe, etc..) are available to prevent Process Hijacking in the batch file by adding an absolute path of .exe in batch file.

I can get this C:\Windows\System32 by using the below command,

%systemroot%\System32\

But I'm afraid that what if all windows don't have their native files always in the "System32".

So my questions are,

  1. Can windows' default system directory will vary depending on windows versions or something?
  2. Can we modify the default system directory ourselves?
  3. These native files(.exe) are always been into the "System32"?

Solution

    1. Can windows' default system directory will vary depending on windows versions or something?

    Yes. The 32 suffix was only added to the System folder when 64bit versions of Windows started existing. Previously it was just C:\Windows\System

    1. Can we modify the default system directory ourselves?

    The name of the folder is hardcoded into the operating system and cannot be changed

    1. These native files(.exe) are always been into the "System32"?

    Taking the cmd.exe file as an example, it has had the same location since Windows XP, but in Windows 95/98 it used to be located directly in C:\Windows directory

    Extra note inspired by comment from cup

    64-bit versions of Windows has a SysWOW64 folder in C:\Windows which (confusingly enough) contains 32bit utilities to support execution of 32-bit applications on a 64-bit system.

    But these are not the commands you're referring to, which will always be found as explained above.