I am creating a script using File.DoesExist to check that a file exists to prevent installing to the wrong location. I thought i was finished as it seems to work. But i realized this checks the file on the system and not the current directory entered in the installation field. i am now trying to use Folder.Find as this has a callbackfunction for currentpath. But i am still having issues and need a little help.
Announcement
Collapse
No announcement yet.
Verify file exists for current installation directory
Collapse
X
-
-
Here is my code that works for checking the entire computer. But i need make it only check the current directory.
Code:-- required files to continue -- Folders -- Check to see if a specific folder exists. folder_exist = Folder.DoesExist("%FSXFiles%".. "\\SimObjects\\Airplanes"); -- Display a dialog telling the user whether or not the folder exists. if folder_exist == false then Screen.Jump("Wrong Location"); else
Comment
-
Originally posted by Ulrich View Post
Please post the relevant code to understand what you are doing - and explain clearly what you want to do.
Ulrich
SOLVED: Unless there is another method this seemed to work and the code change was simple.
I changed the registry session variable to the main AppFolder session variable. Seems the AppFolder is the current directory in the installation field.
Code:-- required files to continue -- Folders -- Check to see if a specific folder exists. folder_exist = Folder.DoesExist("%AppFolder%".. "\\SimObjects\\Airplanes"); -- Display a dialog telling the user whether or not the folder exists. if folder_exist == false then Screen.Jump("Wrong Location"); else
Comment
-
You are not expanding the session variable. Please see the FAQ or refer to the sample code in the product documentation.
Question How do Session Variables work? Answer Session Variables Explained Session variables are used in Setup Factory 7.0 to hold various forms of data that can then be displayed to the user through screens, and/or used in script. For example, %AppFolder% is a Session Variable that has many uses in Setup Factory. When the
Ulrich
Comment
-
Not sure if you saw my last post. I did solve my issue. The reason i am not expanding the default session variable %AppFolder% is because i am not sure the string will work in the above code i use. Also if the user changes the directory the %AppFolder% i have set from the registry will not match and they will be able to install to the wrong location.
Again i could be wrong but it does work. So any reason i want to expand it?
Comment
-
Yes normally a session variable is static because you have a value entered from the session variable settings. So you do want to expand it to use it. But in my case we do not use the settings page we inject the value from our start program option. So what happens is we offer the user to be able to change the destination field if their registry is not up to date anymore and they moved their sim to another drive or location and the registry never got updated. So when they change the destination the %AppFolder% value changes to the new location they just chose. I have tested this and if i use the static value this will not prevent my working code from them installing to any location they want. Our goal is for security and so they do not accidentally install to the wrong location. So after hours of testing only using the session variable works.
Also i thought the point of a session variable was to be able to use the short code so you do not have to enter a long value.
Comment
Comment