Indigo Rose Software

Professional Software Development Tools

 
+ Reply to Thread
Results 1 to 12 of 12
  1. #1
    Join Date
    Nov 2005
    Posts
    92

    Variable question

    Is the %TempFolder% variable represent the temporary folder on the system the install runs on, as the hep sems to indicate, or the folder the setup is running from?

    I have used a PostInstall action to create an entry in an INI file to set a working directory for a program. However, when I check the entry it refers to a folder which does not exists. This is the action I use:

    Code:
    -- CPS.INI
    result = File.DoesExist(SessionVar.Expand("%ApplicationDataFolderCommon%\\%CompanyName%\\%ProductName%\\config\\cps.ini"));
    if result then
    	-- WorkDir
    	CurVal = INIFile.GetValue(SessionVar.Expand("%ApplicationDataFolderCommon%\\%CompanyName%\\%ProductName%\\config\\\\cps.ini"), "CPS", "ScanFolder");
    	if CurVal == "" then
    		INIFile.SetValue(SessionVar.Expand("%ApplicationDataFolderCommon%\\%CompanyName%\\%ProductName%\\config\\\\cps.ini"), "CPS", "WorkDir", SessionVar.Expand("%TempFolder%"));
    	end
    	
    	-- ScanFolder
    	CurVal = INIFile.GetValue(SessionVar.Expand("%ApplicationDataFolderCommon%\\%CompanyName%\\%ProductName%\\config\\\\cps.ini"), "CPS", "ScanFolder");
    	if CurVal == "" then
    		INIFile.SetValue(SessionVar.Expand("%ApplicationDataFolderCommon%\\%CompanyName%\\%ProductName%\\config\\\\cps.ini"), "CPS", "ScanFolder", SessionVar.Expand("%SystemDrive%"));
    	end
    end
    Kevin

  2. #2
    Join Date
    Apr 2005
    Location
    São Paulo, Brazil
    Posts
    2,539
    You could try this:

    Code:
    result = File.DoesExist(SessionVar.Expand("%ApplicationDataFolderCommon%\\%CompanyName%\\%ProductName%\\config\\cps.ini"));
    if result then
        -- WorkDir and ScanFolder
        CurVal = INIFile.GetValue(SessionVar.Expand("%ApplicationDataFolderCommon%\\%CompanyName%\\%ProductName%\\config\\cps.ini"), "CPS", "ScanFolder");
        if CurVal == "" then
            INIFile.SetValue(SessionVar.Expand("%ApplicationDataFolderCommon%\\%CompanyName%\\%ProductName%\\config\\cps.ini"), "CPS", "WorkDir", _TempFolder);
            INIFile.SetValue(SessionVar.Expand("%ApplicationDataFolderCommon%\\%CompanyName%\\%ProductName%\\config\\cps.ini"), "CPS", "ScanFolder", SessionVar.Expand("%SystemDrive%"));
        end
    end
    Additionally, in at the Command Prompt (DOS window), you could check if the TMP/TEMP environment variables are set correctly. At the prompt, type "SET TMP" and press Enter, then "SET TEMP" and press Enter again. Those environment variables should point somewhere, otherwise SUF could have difficulties to define the location of the temporary folder...

    Ulrich
    Last edited by Ulrich; 10-14-2008 at 07:34 PM.

  3. #3
    Join Date
    Nov 2005
    Posts
    92
    Ulrich,

    The code I provided works and does store a value in the INIFile. However, the problem is that the value written is not the same returned by the TMP and TEMP environment variables.

    When the program runs and tries to copy a file to the folder set by the installer it fails because the directory does not exist. That is why I was asking if the variable returned the folder used by the installer (if sub folder of the TEMP) or the TEMP folder itself.

    As yet I have not had a chance to test it on another machine yet.

    Kevin

  4. #4
    Join Date
    Apr 2005
    Location
    São Paulo, Brazil
    Posts
    2,539
    Hi Kevin,

    it makes no little to have a different folder written in the INI file than those appointed to by the environment variables, if you don't change the environment by yourself at some moment of your install...

    If everything else fails, you could try to save _TempFolder into a custom variable in On Startup, and recover that variable instead of _TempFolder when writing the info into the INI file.

    Out of curiosity, what is the path written in your INI file? It should be the TEMP folder by itself, not some subfolder.

    Ulrich

  5. #5
    Join Date
    Nov 2005
    Posts
    92
    Ulrich,

    I do not knowingly change the TEMP folder setting. The code I posted is all the code I have added to the setup.

    When I check the TMP and TEMP enviroment variablesthey both point to a folder called TEMP. After installation checking the INI file the folder is TEMP\2 but that folder does not exist any longer. This is why i was wondering the variable pointed to the folder being used by the installer.

    I will try storing the variable before installation begins, write thatm to the II file and see what happens.

    Kevin

  6. #6
    Join Date
    Jan 2001
    Location
    Anderson Island, WA, USA
    Posts
    2,863
    Quote Originally Posted by KevinD View Post
    Ulrich,

    I do not knowingly change the TEMP folder setting. The code I posted is all the code I have added to the setup.

    When I check the TMP and TEMP enviroment variablesthey both point to a folder called TEMP. After installation checking the INI file the folder is TEMP\2 but that folder does not exist any longer. This is why i was wondering the variable pointed to the folder being used by the installer.

    I will try storing the variable before installation begins, write thatm to the II file and see what happens.

    Kevin
    Are you using RDP to connect to a system?

    For RDP (terminal server) a temp-temp folder is created which is the temporary folder for the user (as if you were at the console) followed by a #. The number is your session #.

    Terminal server automatelly removes this folder when you log out.

    this is so that if you login twice, your temp files do not collide with your other sessions.


    (Click here to contact me)
    Providing Independent Professional Consulting Services for
    IndigoRose products, World Wide.
    Located in -8:00 (-7:00 DST) GMT Timezone (Western United States)

  7. #7
    Join Date
    Nov 2005
    Posts
    92
    I am indeed logging in remotely. It had not occured to me that the folder would be specific to the login and then removed afterwards. Makes sense.

    Now to find way a way around it, removing that last folder level. Or I ight just create a working directory for the progrm.

    Thanks for the help.

    Kevin

  8. #8
    Join Date
    Jan 2001
    Location
    Anderson Island, WA, USA
    Posts
    2,863
    you could use _TempFolder .. "\\.." to get "above"

    so; something like: (on startup)


    Code:
    if String.Find("0123456789",  String.Right( _TempFolder,1)) > 0 then
    	cTempFolder = _TempFolder .. "\\..";
    else
    	cTempFolder = _TempFolder 
    end
    And then use cTempFolder in your script instead of _TempFolder.
    I don't like to change "built in" variables, as other scripts may rely on them being "right".

    Another folder you could use is
    Code:
    _WindowsFolder.."\\temp";
    but that would require you to have rights to it...
    Last edited by jassing; 10-17-2008 at 08:22 AM.


    (Click here to contact me)
    Providing Independent Professional Consulting Services for
    IndigoRose products, World Wide.
    Located in -8:00 (-7:00 DST) GMT Timezone (Western United States)

  9. #9
    Join Date
    Nov 2005
    Posts
    92
    I could not get the code to pick up the folder correctly. It kept using a sub folder of the TEMP and sometimes looking in the INI file it did not look like a valid path ( had '\...\' in the middle of it). Using the selection option in the program indicated the folder did not exist. The code is below.

    Code:
    --cTempStart = SessionVar.Expand("%TempFolder%")
    cTempStart = _TempFolder
    nLast = String.ReverseFind(cTempStart, "\\Temp", false);
    nLast = nLast + 6
    
    sTempFolder = String.AbbreviateFilePath(cTempStart, nLast);
    --cTempFolder = _TempFolder;
    
    --if String.Find("0123456789",  String.Right( _TempFolder,1)) > 0 then
    --	cTempFolder = _TempFolder .. "\\..";
    --else
    --	cTempFolder = _TempFolder 
    --end
    In the end I resorted to creating a sub folder in the config folder and set that in the INI. Not the solution I was aiming for but it will work.

    Thanks for the help.

    Kevin

  10. #10
    Join Date
    Jan 2001
    Location
    Anderson Island, WA, USA
    Posts
    2,863
    Not sure where the 3 periods would be coming from.
    with your nlast, shouldn't it be 5 not 6? "\\temp" is 5 characters long...

    -josh


    (Click here to contact me)
    Providing Independent Professional Consulting Services for
    IndigoRose products, World Wide.
    Located in -8:00 (-7:00 DST) GMT Timezone (Western United States)

  11. #11
    Join Date
    Nov 2005
    Posts
    92
    I initially tried it with 5 but it did not seem to work. My understanding from the help file was that it would return a valid path trimming the end off till it got one. The 6 was tor try force it to the 'temp' without success.

    Kevin

  12. #12
    Join Date
    Jan 2001
    Location
    Anderson Island, WA, USA
    Posts
    2,863
    I still think using the ".." is a better way to go.


    (Click here to contact me)
    Providing Independent Professional Consulting Services for
    IndigoRose products, World Wide.
    Located in -8:00 (-7:00 DST) GMT Timezone (Western United States)

Similar Threads

  1. Replies: 1
    Last Post: 06-18-2004, 09:48 AM
  2. using %versionfoundName% variable...question
    By Mattias Klasson in forum Visual Patch 1.0
    Replies: 0
    Last Post: 05-24-2004, 06:51 AM
  3. Replies: 1
    Last Post: 11-21-2001, 01:10 PM
  4. Registry Variable Failure
    By ggallo in forum Setup Factory 5.0
    Replies: 3
    Last Post: 08-30-2001, 01:51 PM
  5. Validation of custom variable references?
    By John Schacher in forum Setup Factory 5.0
    Replies: 1
    Last Post: 07-18-2000, 01:26 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts