Indigo Rose Software
  #1  
Old 10-14-2008
KevinD KevinD is offline
Forum Member
 
Join Date: Nov 2005
Posts: 50
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
Reply With Quote
  #2  
Old 10-14-2008
Ulrich's Avatar
Ulrich Ulrich is offline
Indigo Rose Staff Member
 
Join Date: Apr 2005
Location: Sao Paulo, Brazil
Posts: 823
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 08:34 PM.
Reply With Quote
  #3  
Old 10-15-2008
KevinD KevinD is offline
Forum Member
 
Join Date: Nov 2005
Posts: 50
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
Reply With Quote
  #4  
Old 10-15-2008
Ulrich's Avatar
Ulrich Ulrich is offline
Indigo Rose Staff Member
 
Join Date: Apr 2005
Location: Sao Paulo, Brazil
Posts: 823
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
Reply With Quote
  #5  
Old 10-17-2008
KevinD KevinD is offline
Forum Member
 
Join Date: Nov 2005
Posts: 50
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
Reply With Quote
  #6  
Old 10-17-2008
jassing's Avatar
jassing jassing is offline
Indigo Rose Customer
 
Join Date: Jan 2001
Location: Anderson Island, WA, USA
Posts: 1,899
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.
__________________
Reply With Quote
  #7  
Old 10-17-2008
KevinD KevinD is offline
Forum Member
 
Join Date: Nov 2005
Posts: 50
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
Reply With Quote
  #8  
Old 10-17-2008
jassing's Avatar
jassing jassing is offline
Indigo Rose Customer
 
Join Date: Jan 2001
Location: Anderson Island, WA, USA
Posts: 1,899
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 09:22 AM.
Reply With Quote
  #9  
Old 10-18-2008
KevinD KevinD is offline
Forum Member
 
Join Date: Nov 2005
Posts: 50
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
Reply With Quote
  #10  
Old 10-18-2008
jassing's Avatar
jassing jassing is offline
Indigo Rose Customer
 
Join Date: Jan 2001
Location: Anderson Island, WA, USA
Posts: 1,899
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
__________________
Reply With Quote
  #11  
Old 10-19-2008
KevinD KevinD is offline
Forum Member
 
Join Date: Nov 2005
Posts: 50
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
Reply With Quote
  #12  
Old 10-19-2008
jassing's Avatar
jassing jassing is offline
Indigo Rose Customer
 
Join Date: Jan 2001
Location: Anderson Island, WA, USA
Posts: 1,899
I still think using the ".." is a better way to go.
__________________
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Yet another question on setting the path environmental variable bsd_mike Setup Factory 6.0 1 06-18-2004 10:48 AM
using %versionfoundName% variable...question Mattias Klasson Visual Patch 1.0 0 05-24-2004 07:51 AM
SUF 6.0.0.0 Bug: Loosing def variable in radio buttons screen pit Setup Factory 5.0 1 11-21-2001 02:10 PM
Registry Variable Failure ggallo Setup Factory 5.0 3 08-30-2001 02:51 PM
Validation of custom variable references? John Schacher Setup Factory 5.0 1 07-18-2000 02:26 PM


All times are GMT -6. The time now is 03:58 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Copyright © 2000 - 2009 Indigo Rose Corporation. All rights reserved.
Indigo Rose Software