PDA

View Full Version : Create folder in ROOT Fails



CMS Software
07-09-2014, 02:33 PM
We never know whether our users are running 32 or 64 versions of XP, Win 7 or Win 8.1. In the old XP versions, there was no "ProgramData" folder but in the later Windows versions there is. We found that attempting to "create" a folder that already exists does not generate an error. We use the following code which will create the folder if it is not there and which will generate no error if it is there.

=====

If %_SB_ROOT%\PROGRAMDATA File or Folder doesn't exist Then
::Create Folder "%_SB_ROOT%\ProgramData" (Always Install)
If %_SB_ERRORCODE% Equals "0" Then
Display Message Box "The creation of C:\ProgramData FAILED!" -- "Create Folder ProgramData"
End
End
Set File Attributes for "%_SB_ROOT%\PROGRAMDATA"

=====

On some machines running Windows 7 Professional 64 bit, it fails every time. Other users have no errors. We also create other folders under PROGRAMDATA and if the "%_SB_ROOT%\PROGRAMDATA" creation fails, then obviously all the sub folders fail also.

As a side question, on all Windows computers isn't %_SB_ROOT% always the "C:" drive?

Thanks
-O. D.-

linder
07-10-2014, 01:48 AM
Hello,

First of all, what you are trying to do is "suboptimal" (not recommended) in Windows (and on Vista+ not even allowed). The "All Users" profile in Windows XP is now stored in the hidden %SystemDrive%\ProgramData folder in Windows Vista and above. I would suggest to always use the correct locations for your application (see Windows development guidelines).

BTW, the %_SB_ROOT% runtime variable contains the root drive letter of the installation folder. It is not guaranteed to be the C: drive.

Friedrich

linder
07-10-2014, 01:51 AM
BTW, %WINVER% gives you the Windows version and "Get System Info (WOW64 Status)" lets you retrieve the OS "bitness" (32 or 64 bit). So you always have control over this process even if you don't know what kind of operating system your users have.

Friedrich

CMS Software
07-10-2014, 11:56 AM
On a Windows 7 64 bit machine, "Get System Info (WOW64 Status)" returns a value of 1. I assume that a 32 bit machine would return "0"? Couldn't find the answer in the Help PDF nor in "Common Definitions.sbi".

-O. D.-

linder
07-10-2014, 12:11 PM
Yes, it only returns 1 on Windows x64 machines. Otherwise, it returns 0.

Friedrich