|
#1
|
|||
|
|||
|
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
|
|
#2
|
||||
|
||||
|
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
Ulrich Last edited by Ulrich; 10-14-2008 at 08:34 PM. |
|
#3
|
|||
|
|||
|
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
|
||||
|
||||
|
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
|
|||
|
|||
|
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
|
||||
|
||||
|
Quote:
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. |
|
#7
|
|||
|
|||
|
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
|
||||
|
||||
|
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
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"; Last edited by jassing; 10-17-2008 at 09:22 AM. |
|
#9
|
|||
|
|||
|
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
Thanks for the help. Kevin |
|
#10
|
||||
|
||||
|
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 |
|
#11
|
|||
|
|||
|
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
|
||||
|
||||
|
I still think using the ".." is a better way to go.
|
![]() |
«
Previous Thread
|
Next Thread
»
| Thread Tools | |
| Display Modes | |
|
|
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.









Linear Mode

