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,
- Can windows' default system directory will vary depending on windows versions or something?
- Can we modify the default system directory ourselves?
- These native files(.exe) are always been into the "System32"?
Yes. The 32 suffix was only added to the
Systemfolder when 64bit versions of Windows started existing. Previously it was justC:\Windows\SystemThe name of the folder is hardcoded into the operating system and cannot be changed
Taking the
cmd.exefile as an example, it has had the same location since Windows XP, but in Windows 95/98 it used to be located directly inC:\WindowsdirectoryExtra note inspired by comment from cup
64-bit versions of Windows has a
SysWOW64folder inC:\Windowswhich (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.