Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it safe to assume that the path C:\WINDOWS\system32 always exists?

On OS from win 2000 or later (any language) can I assume that this path will always exists? For example I know that on win xp in some languages the "Program Files" directory have a different name. So is it true for the System32 folder?

Thanks. Ohad.

like image 795
Ohad Horesh Avatar asked Oct 27 '08 06:10

Ohad Horesh


People also ask

Is System32 a protected folder?

The malware is inside the AppData folder in your User folder, it is not in System32 or the ProgramData folders, the System32 folder is highly protected and it would be very rare for malware to be able to access that folder.

Is System32 on the path?

The System32 located under The C:\Windows\System32 directory is a critical part of the Windows OS that contains important system files.

Is it safe to delete files from System32?

The System32 Folder is a core folder in Windows OS. It contains important operating system files and folders that are necessary for the smooth functioning of your system. If this folder gets deleted or corrupted, it can cause serious problems with your computer.

Why does Windows System32 appear?

What Causes the System32 Folder Pop up at Startup? According to our investigations, the main cause of the problem is: Service or Application Interference: There is a great chance that a third party application installed on your computer or a Windows service is causing this issue.


3 Answers

You definitely cannot assume that: Windows could be installed on a different drive letter, or in a different directory. On a previous work PC Windows was installed in D:\WINNT, for example.

The short answer is to use the API call GetSystemDirectory(), which will return the path you are after.

The longer answer is to ask: do you really need to know this? If you're using it to copy files into the Windows directory, I'd suggest you ask if you really want to do this. Copying into the Windows directory is not encouraged, as you can mess up other applications very easily. If you're using the path to find DLLs, why not just rely on the OS to find the appropriate one without giving a path? If you're digging into bits of the OS files, consider: is that going to work in future? In general it's better to not explicitly poke around in the Windows directory if you want your program to work on future Windows versions.

like image 74
DavidK Avatar answered Oct 12 '22 11:10

DavidK


No, you can't assume that.

Windows can be installed to a different path. One solution is to look for it by calling GetSystemDirectory (implemented as part of the Windows API).

like image 22
vmarquez Avatar answered Oct 12 '22 12:10

vmarquez


Windows can be installed on a different harddrive and or in a different folder. Use the %windir% or %systemroot% environment variables to get you to the windows folder and append system32. Or use the %path% variable, it's usually the first entrance and the preferred method of searching for files such as dlls AFAIK. As per comments: don't rely too much on the system32 dir being the first item. I do think it's safe to assume it's in %path% somewhere though.

like image 42
Jasper Bekkers Avatar answered Oct 12 '22 11:10

Jasper Bekkers