%WINDIR% reports wrong folder on Windows Server 2003

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • jinjoid
    Indigo Rose Customer
    • Jun 2003
    • 26

    %WINDIR% reports wrong folder on Windows Server 2003

    I am writing an app that is for Windows 2003 Server and everything has been going well until I try and install it. I have to edit an INI file in the windows folder but instead of returning c:\windows in %WINDIR% setup factory is returning c:\Documents and Settings\Administrator\Windows (which allows programs to write into the windows folder even as a standard user as it isn't the "real" windows folder i.e. more apps run)

    The environment variable WINDIR is set to c:\windows if I type set at a command prompt.

    If I run "change user /install" before running the setup program then the correct value is obtained by Setup Factory. I have tried running "change user /install" from within setup factory and the machine does go into install mode, but by that time Setup Factory has already "retrieved" the value of %WINDIR% and it is incorrect. Here is the code I am running.

    Assign Value (%phpini% = %WinDir%\php.ini)
    Read File Information (%phpiniexists% = Existence of %phpini%)
    IF (%phpiniexists% = FALSE)
    Show Message Box (File not found: '%phpini%. Aborting Setup.)
    Abort Setup
    END IF
    Modify INI File (Set Value: %phpini% [PHP]: register_globals = off)


    Does anyone know how to force Setup Factory to obtain the correct WINDIR or check that is in install mode. I could say that the user installing the software must put the machine into install mode, but someone is always going to get it wrong.

    Any ideas anyone?

    Jinjoid
  • Darryl
    Indigo Rose Staff Member
    • Jul 2001
    • 1908

    #2
    Re: %WINDIR% reports wrong folder on Windows Server 2003

    Unfortunately I don't have access to a Windows Server 2003 system to verify this occurrance, however I do have a couple suggestions for you.

    If I'm not mistaken, it sounds like you first want to know whether the user logged in has administrative permissions. For that you can use the built-in variable %IsUserNTAdmin%.

    Another method for detecting the current Windows directory may be reading the environment variable on the system to get the path. You can find information about Environment variables in the following Knowledge Base article:

    Click Here

    I also want to make sure you are using the latest build of the product, 6.0.1.2.

    Has anyone else experienced this behavior? Either way, I will submit a bug report to have it looked into.

    Comment

    • jinjoid
      Indigo Rose Customer
      • Jun 2003
      • 26

      #3
      Re: %WINDIR% reports wrong folder on Windows Server 2003

      Yes I am using 6.0.1.2

      Using the environment variable is a valid solution and I will give it a go. The administrative permissions aren't really the issue I already check that the user is admin, the OS just gives each user their own windows folder rather than the real windows folder. Is it possible to know where Setup Factory obtains the windows folder from (registry key?) then I can see immediately whether that is the problem.

      Cheers

      Jinjoid

      Comment

      • jinjoid
        Indigo Rose Customer
        • Jun 2003
        • 26

        #4
        Re: %WINDIR% reports wrong folder on Windows Server 2003

        OK this has now gone officially weird. I tried reading from HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Contro l\Session Manager\Environment\windir and everything is OK with that, my problem is solved but I did some more testing to see if I could find out the problem (I don't like unexplained solutions). This is what I did, the results are too weird.

        Created a new project with default settings and added the following actions to the startup tab

        Read from Registry (%RegistryVar% = HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Contro l\Session Manager\Environment\windir)
        Show Message Box (%RegistryVar%)
        Show Message Box (%WinDir%)
        Assign Value (%phpini% = %WinDir%\php.ini)
        Show Message Box (%phpini%)

        Built the project and ran it, the Value obtained from the registry was c:\windows the value received from builtin WinDir was c:\windows the phpini variable was set to c:\windows\php.ini i.e. Everything was correct.

        Loaded up my real project and added the same actions to the startup tab built it and ran it. The results I got were.

        Value obtained from the registry was c:\windows the value received from builtin WinDir was c:\Documents and Settings\Administrator\windows the phpini variable was set to c:\Documents and Settings\Administrator\windows\php.ini

        How is that possible! Is there a project setting that I have inadvertently set that could cause this behaviour? I'm at a loss.

        Jinjoid

        Comment

        • Darryl
          Indigo Rose Staff Member
          • Jul 2001
          • 1908

          #5
          Re: %WINDIR% reports wrong folder on Windows Server 2003

          That is certainly strange and I'm not sure how to explain that one either. No, there isn't anything special that would need to be set. Are you sure you are logged in the same way when you launch each install?

          The built-in variable %WinDir% is currently populated using a Windows API function called GetWindowsDirectory(). I'm not sure internally what that function looks at though.

          Comment

          • jinjoid
            Indigo Rose Customer
            • Jun 2003
            • 26

            #6
            Re: %WINDIR% reports wrong folder on Windows Server 2003

            Yeah definitely logged in with the same user both tests, good to know how the Windir is set I will write a few test apps and investigate further.

            Cheers

            Jinjoid

            Comment

            Working...
            X