Hi all,
Any help welcomed. I am an IT admin with limited coding experience, so can’t see where I have gone wrong.
I am trying to create a simple app launcher (to lockdown a desktop PC)
I have managed successfully to use a hardcoded path, which is fine right now.
However I would like to finish the job and move to a simple txt file in the same folder as the launcher that contains the path. this way if a new version of the program lands with a different path I dont have to re-code, just change the text file.
my current attempt :-
Dim f As FolderItem
Dim axp As String
f = SpecialFolder.UserHome.child(“axpath.txt”)
// All the file types in this set
if f <> nil and f.exists then
Dim t As TextInputStream
Try
t = TextInputStream.Open(f)
t.Encoding = Encodings.MacRoman
axp = t.ReadAll
Catch e As IOException
t.Close
MsgBox(“Error accessing file.”)
End Try
end if
Dim ax As New Shell
ax.Execute axp
Does not error during build, equally doesnt actually run the software.
Have you considered that the path might be wrong, or contain a space?
Are you storing the ShellPath or the NativePath?
Also, if axpath.txt is missing, ax.Execute axp is getting executed anyway…
axp could be empty!
You do a ‘readall’… are there more than one apps you want to launch?
because you dont loop through the lines, you just use the whole file at once here
try:
Dim f As FolderItem
Dim axp As String
Dim t As TextInputStream
f = SpecialFolder.UserHome.child(“axpath.txt”)
if f <> nil and f.exists then
Try
t = TextInputStream.Open(f)
axp = t.ReadLine //first line only here.. use a loop if there are more
t.Close
Catch e As IOException
t.Close
MsgBox(“Error accessing file.”)
End Try
if axp <> "" then
Dim ax As New Shell
ax.Execute axp
end if
else
msgbox "Unable to locate axpath.txt"
end if
Hi All,
Many thanks for all your help.
It would appear removing the “t.encoding” line was a help,
However, the text file being in the same location as the program needed
f = SpecialFolder.UserHome.child(“axpath.txt”)
Changed to :-
f = SpecialFolder.CurrentWorkingDirectory.child(“axpath.txt”)
once I realised the SpecialFolder had options I was able to work out my mistake.
Thanks again for the assistance, and hope me posting the solution helps someone else out in the future.