Problem using custom Windows shortcuts in Celestia education
Forum rules
Please help to make this forum more useful by checking the FAQs before posting! Keep it clean, keep it civil, keep it truthful, stay on topic, be responsible, share your knowledge.
Please help to make this forum more useful by checking the FAQs before posting! Keep it clean, keep it civil, keep it truthful, stay on topic, be responsible, share your knowledge.
-
Topic authorfsgregs
- Posts: 1307
- Joined: 07.10.2002
- With us: 22 years 1 month
- Location: Manassas, VA
Problem using custom Windows shortcuts in Celestia education
Hi everyone;
I could really use your help in solving what so far, has been an intractable problem. As many of you may know, I offer a series of educational journeys for use in Celestia. You can find them all for download on the motherlode. Each journey consists of an Activity document written in MS Word (OpenOffice will also work fine), a student worksheet for students to complete, and a set of customized addons that are arranged and tailored for use in each journey. These activities use a customized version of Celestia called Celestia160-ED.
The educational offering includes a fully functional version of Celestia plus lots of other files (2.5 GB), all installed into its own directory on a user's PC. The default directory for installation is C:\Program Files\Celestia160-ED.
To use an Activity, a user first double-clicks on a specific Windows shortcut that launches Celestia160-ED.exe. That shortcut contains a specific hard-coded command line that tells Celestia to consult a specific config file in order to launch the application. That custom cfg file in turn, contains code that loads only certain add-ons, sets custom parameters for Celestia160-ED to open with, calls a specific start.celx script file, etc. Since I have 12 educational journeys, I have 12 hard-coded Windows shortcut files, each with a different command line. Here is a screenshot of the Properties menu in one such shortcut:
The command line is in the Target field, and ends with " --conf Activity3-160.cfg"
This all works great, but a problem is now surfacing. This Windows shortcut has to be hard-coded because of the command line. As such, the "Target" line, and the "Start in" line must have values in it specifying what directory to look in to locate Celestia160-ED, and its proper cfg files. For the longest time, I have simply used the default directory that I recommend all users install the educational activities into, namely; "C:\Program Files". This works fine IF and only IF a user installs Celestia160-ED into that directory.
However, if they do not, and choose to install Celestia-ED into a different drive such as "D:\Program files", or "J:\Apps", or .... then the shortcut cannot find the directory, and none of the shortcuts work at all. A user has to open the Properties menu of each shortcut and manually change the "Target" and "Start in" lines to reflect the directory he loaded Celestia160-ED into.
This problem recently became worse with the release of Windows 7. Windows 7 automatically places all 32 bit programs into a new directory called "C:\Program Files (x86)". Consequently, NONE of the Activities now work on Windows 7, until the user edits all the shortcuts.
Marco Klunder and I have been researching a fix for this and have tried many things ... so far without success. We tried using general Windows "environment variables" in place of the directory path. For example, I substituted C:\program files, with %programfiles% in each of the two lines. The "Target" line would then read,
"%programfiles%\Celestia160-ED\celestia160-ED.exe" -- conf Activity3-160.cfg. Likewise, the Start In line would read, "%programfiles%\Celestia160-ED"
It doesn't work. If a user has installed the educational activities on any drive other than C:, they get an error message that Celestia cannot find the cfg file.
Marco and I have tried setting a custom environment variable. That didn't work either, since the user does not have their own custom environment variable on their system.
The problem seems to be in the "Start in" line. The shortcut just loses its way, until the user edits all the shortcuts and types the exact path to the Celestia160-ED folder in that line. That is really something a user should not have to do. Many of the users are kids and I don't want them having to edit Windows shortcut Properties menus.
Does anyone have any suggestions here? Is there an "environment variable" I'm unaware of that can be typed as the directory address for both the Target and Start In lines, that will point the shortcut to a folder or app or file where-ever it is installed on a PC?
Alternatively, I am using the program "Inno Installer" to create the Windows installer file for the educational activities. Is there a line I can type in Inno Installer that will create dynamic Windows shortcuts at the time of installation, that INCLUDE the command line parameter I need?
Thank you so much in advance for any help you can give us.
Regards
Frank
I could really use your help in solving what so far, has been an intractable problem. As many of you may know, I offer a series of educational journeys for use in Celestia. You can find them all for download on the motherlode. Each journey consists of an Activity document written in MS Word (OpenOffice will also work fine), a student worksheet for students to complete, and a set of customized addons that are arranged and tailored for use in each journey. These activities use a customized version of Celestia called Celestia160-ED.
The educational offering includes a fully functional version of Celestia plus lots of other files (2.5 GB), all installed into its own directory on a user's PC. The default directory for installation is C:\Program Files\Celestia160-ED.
To use an Activity, a user first double-clicks on a specific Windows shortcut that launches Celestia160-ED.exe. That shortcut contains a specific hard-coded command line that tells Celestia to consult a specific config file in order to launch the application. That custom cfg file in turn, contains code that loads only certain add-ons, sets custom parameters for Celestia160-ED to open with, calls a specific start.celx script file, etc. Since I have 12 educational journeys, I have 12 hard-coded Windows shortcut files, each with a different command line. Here is a screenshot of the Properties menu in one such shortcut:
The command line is in the Target field, and ends with " --conf Activity3-160.cfg"
This all works great, but a problem is now surfacing. This Windows shortcut has to be hard-coded because of the command line. As such, the "Target" line, and the "Start in" line must have values in it specifying what directory to look in to locate Celestia160-ED, and its proper cfg files. For the longest time, I have simply used the default directory that I recommend all users install the educational activities into, namely; "C:\Program Files". This works fine IF and only IF a user installs Celestia160-ED into that directory.
However, if they do not, and choose to install Celestia-ED into a different drive such as "D:\Program files", or "J:\Apps", or .... then the shortcut cannot find the directory, and none of the shortcuts work at all. A user has to open the Properties menu of each shortcut and manually change the "Target" and "Start in" lines to reflect the directory he loaded Celestia160-ED into.
This problem recently became worse with the release of Windows 7. Windows 7 automatically places all 32 bit programs into a new directory called "C:\Program Files (x86)". Consequently, NONE of the Activities now work on Windows 7, until the user edits all the shortcuts.
Marco Klunder and I have been researching a fix for this and have tried many things ... so far without success. We tried using general Windows "environment variables" in place of the directory path. For example, I substituted C:\program files, with %programfiles% in each of the two lines. The "Target" line would then read,
"%programfiles%\Celestia160-ED\celestia160-ED.exe" -- conf Activity3-160.cfg. Likewise, the Start In line would read, "%programfiles%\Celestia160-ED"
It doesn't work. If a user has installed the educational activities on any drive other than C:, they get an error message that Celestia cannot find the cfg file.
Marco and I have tried setting a custom environment variable. That didn't work either, since the user does not have their own custom environment variable on their system.
The problem seems to be in the "Start in" line. The shortcut just loses its way, until the user edits all the shortcuts and types the exact path to the Celestia160-ED folder in that line. That is really something a user should not have to do. Many of the users are kids and I don't want them having to edit Windows shortcut Properties menus.
Does anyone have any suggestions here? Is there an "environment variable" I'm unaware of that can be typed as the directory address for both the Target and Start In lines, that will point the shortcut to a folder or app or file where-ever it is installed on a PC?
Alternatively, I am using the program "Inno Installer" to create the Windows installer file for the educational activities. Is there a line I can type in Inno Installer that will create dynamic Windows shortcuts at the time of installation, that INCLUDE the command line parameter I need?
Thank you so much in advance for any help you can give us.
Regards
Frank
Re: Problem using custom Windows shortcuts in Celestia education
Hello,
I suggest to replace your link by a two-lines command file in the "Activity_cels" directory :
if you need an actual link, just make it point to this command file
I suggest to replace your link by a two-lines command file in the "Activity_cels" directory :
Code: Select all
cd..
start celestia160-ED.exe --conf Activity3-160.cfg
if you need an actual link, just make it point to this command file
- Marco Klunder
- Posts: 181
- Joined: 20.02.2008
- Age: 62
- With us: 16 years 9 months
- Location: The Netherlands
Re: Problem using custom Windows shortcuts in Celestia education
Primarily, I got this suggestion of Jo?l work here (as easy, as simple ),
The "Activity4.bat" file as mentioned in the hyperlink contains both lines of Jo?l's code (for Activity4 in this case).
But unfortunately, there resides a great potential problem in this solution...
Between openening the document and clicking the link, NOTHING in the system may change the ACTIVE directory.
As I already experienced with testing the suggested solution and taking the snapshot above, the snapshot program did meanwhile reset the active directory, resulting in the following error:
Another issue not related to the sugested solution, but still part of Franks problem:
The Activity document shortcut also contains an "hard-coded" reference to C:\Program Files\Celestia160-ED\Educational-Activities.
Marco
The "Activity4.bat" file as mentioned in the hyperlink contains both lines of Jo?l's code (for Activity4 in this case).
But unfortunately, there resides a great potential problem in this solution...
Between openening the document and clicking the link, NOTHING in the system may change the ACTIVE directory.
As I already experienced with testing the suggested solution and taking the snapshot above, the snapshot program did meanwhile reset the active directory, resulting in the following error:
Another issue not related to the sugested solution, but still part of Franks problem:
The Activity document shortcut also contains an "hard-coded" reference to C:\Program Files\Celestia160-ED\Educational-Activities.
Marco
Marco Klunder
email: marco.klunder@xs4all.nl
Windows10 PD 3.0 GHz, 2 GB of RAM, Nvidia GeForce 6700 XL
Celestia161 / SVN + Lua Edu Tools v1.2 Beta9, Celestia160-ED and Celestia1621
email: marco.klunder@xs4all.nl
Windows10 PD 3.0 GHz, 2 GB of RAM, Nvidia GeForce 6700 XL
Celestia161 / SVN + Lua Edu Tools v1.2 Beta9, Celestia160-ED and Celestia1621
-
Topic authorfsgregs
- Posts: 1307
- Joined: 07.10.2002
- With us: 22 years 1 month
- Location: Manassas, VA
Re: Problem using custom Windows shortcuts in Celestia education
Jogad:
The problem is that when the Activities are installed in a different drive or directory, the windows shortcut that I use cannot find the Activity_cels folder, because it is not on the C:\Program files drive. Thus, it would have the same problem finding the 2 line bat file as it would finding the actual Windows shortcut file. The Celestia160-ED folder is not where the shortcut is looking for it!
I need a means of creating and coding a Windows shortcut in advance and including it in the installation that will update itself automatically by finding the location of the Celestia160-ED folder, wherever it may be, on any drive.
Actually, this problem occurs even if there is no command line to fool with. For example, try this. Create a shortcut to the celestia.exe app in version 1.6.0. Place the shortcut in its own folder inside the Celestia root directory (called it the "test" folder). Now click on the shortcut. Celestia will launch.
Now, install Celestia 1.6.0 again, on a different computer, in a different directory (not C:\Program Files). Copy and paste the "test" folder and shortcut you created earlier into Celestia on the 2nd computer. Click on the shortcut. Celestia will not launch, because that shortcut is looking inside C:\Program Files for the app, and is not finding celestia.exe.
How do programmers include shortcuts with their apps that automatically update to point to the correct address at the time of installation? There must be some environment variable or trick to do this.
Frank
The problem is that when the Activities are installed in a different drive or directory, the windows shortcut that I use cannot find the Activity_cels folder, because it is not on the C:\Program files drive. Thus, it would have the same problem finding the 2 line bat file as it would finding the actual Windows shortcut file. The Celestia160-ED folder is not where the shortcut is looking for it!
I need a means of creating and coding a Windows shortcut in advance and including it in the installation that will update itself automatically by finding the location of the Celestia160-ED folder, wherever it may be, on any drive.
Actually, this problem occurs even if there is no command line to fool with. For example, try this. Create a shortcut to the celestia.exe app in version 1.6.0. Place the shortcut in its own folder inside the Celestia root directory (called it the "test" folder). Now click on the shortcut. Celestia will launch.
Now, install Celestia 1.6.0 again, on a different computer, in a different directory (not C:\Program Files). Copy and paste the "test" folder and shortcut you created earlier into Celestia on the 2nd computer. Click on the shortcut. Celestia will not launch, because that shortcut is looking inside C:\Program Files for the app, and is not finding celestia.exe.
How do programmers include shortcuts with their apps that automatically update to point to the correct address at the time of installation? There must be some environment variable or trick to do this.
Frank
Re: Problem using custom Windows shortcuts in Celestia education
Hello Marco
I begin by the second problem
I you need a shortcut for example on the desktop, just make it with the classical method of drag and drop with the right mouse button.
Two more lines to add to the command file
Note the very clear and evident syntax of DOS commands
I begin by the second problem
I don't understand why you launch the doc files with a shortcut when it is so simple to launch them by clicking directly on them.Marco Klunder wrote:The Activity document shortcut also contains an "hard-coded" reference to C:\Program Files\Celestia160-ED\Educational-Activities.
I you need a shortcut for example on the desktop, just make it with the classical method of drag and drop with the right mouse button.
Here is the solution for thatMarco Klunder wrote:But unfortunately, there resides a great potential problem in this solution...
Between openening the document and clicking the link, NOTHING in the system may change the ACTIVE directory.
Two more lines to add to the command file
Code: Select all
for %%i in (%~p0) do set chemin=%%i
cd %chemin%
cd ..
start celestia160-ED.exe --conf Activity3-160.cfg
Note the very clear and evident syntax of DOS commands
- Marco Klunder
- Posts: 181
- Joined: 20.02.2008
- Age: 62
- With us: 16 years 9 months
- Location: The Netherlands
Re: Problem using custom Windows shortcuts in Celestia education
jogad wrote:I don't understand why you launch the doc files with a shortcut when it is so simple to launch them by clicking directly on them.
E.G. Especially in network server environments (school labs), Celestia may be installed somewhere on a central server.
The activity shortcut are copied to the individual school computers an must point to the Celestia environment on the central server.
This matches the problem Frank answeres above.
By the way, the "clear and evident" syntax of DOS commands isn't working.
What I did:
1) Open the Word document
2) Open and save Activity4.bat with Notepad++
3) Click on the Hyperlink in the Word docuyment
(I think it has also to do with Celestia residing on e different drive (In my case the D: drive, but it can be any possible drive letter), looking at the syntax messages)
Marco
Marco Klunder
email: marco.klunder@xs4all.nl
Windows10 PD 3.0 GHz, 2 GB of RAM, Nvidia GeForce 6700 XL
Celestia161 / SVN + Lua Edu Tools v1.2 Beta9, Celestia160-ED and Celestia1621
email: marco.klunder@xs4all.nl
Windows10 PD 3.0 GHz, 2 GB of RAM, Nvidia GeForce 6700 XL
Celestia161 / SVN + Lua Edu Tools v1.2 Beta9, Celestia160-ED and Celestia1621
Re: Problem using custom Windows shortcuts in Celestia education
Frank, Marco, Salut
This is now a solution that works for me
To test it in the worst conditions, I have installed Celestia-ED on a remote computer 'Bernadette-pc'
The remote pc is running Windows7 and mine has Windows XP3
Here are the steps to follow
1) If you are on a network you must assign a drive letter to your network path because command files don't reconize UNC names.
For me it is Z:
2) In the original Activity_cels directory replace the *.lnk files by a command file like this:
Note that only the last line is different for each activity.
3) In the original Activity_shortcuts directory, edit the document files by replacing the "lnk" extension by "bat" in the hyperlink adress as you already did before.
4) On the client computer create a shortcut (not a copy) of the Activity_cels directory on Z: by dragging on the desktop (or elsewhere)
5) By the same way, create a shortcut for the activities docs. But do not use the Activity_Shorcuts folder (forget it). Instead create the shortcut from the Educational-Activities folder.
When you double-click on the shortcut that opens the actual directory in the other drive and you can now safely double-click
This was a first step to a solution and I had not understood the problem very wellMarco Klunder wrote:By the way, the "clear and evident" syntax of DOS commands isn't working.
This is now a solution that works for me
To test it in the worst conditions, I have installed Celestia-ED on a remote computer 'Bernadette-pc'
The remote pc is running Windows7 and mine has Windows XP3
Here are the steps to follow
1) If you are on a network you must assign a drive letter to your network path because command files don't reconize UNC names.
For me it is Z:
2) In the original Activity_cels directory replace the *.lnk files by a command file like this:
Code: Select all
@echo off
echo searching for Celestia-ED
echo wait a moment...
for %%i in (%~d0) do set letter=%%i
for %%i in (%~p0) do set chemin=%%i
%letter%
cd %chemin%
cd ..
start celestia160-ED.exe --conf Activity4-160.cfg
Note that only the last line is different for each activity.
3) In the original Activity_shortcuts directory, edit the document files by replacing the "lnk" extension by "bat" in the hyperlink adress as you already did before.
4) On the client computer create a shortcut (not a copy) of the Activity_cels directory on Z: by dragging on the desktop (or elsewhere)
5) By the same way, create a shortcut for the activities docs. But do not use the Activity_Shorcuts folder (forget it). Instead create the shortcut from the Educational-Activities folder.
When you double-click on the shortcut that opens the actual directory in the other drive and you can now safely double-click
- - on the command file in Activity_cels
- on the document file in Educational-Activities
- Marco Klunder
- Posts: 181
- Joined: 20.02.2008
- Age: 62
- With us: 16 years 9 months
- Location: The Netherlands
Re: Problem using custom Windows shortcuts in Celestia education
Hello Jo?l, Frank,
The "clear and evident syntax of DOS commands" begin to work now
As far as I tested this, it's working perfect , although creating the shortcuts remain a manual action and is still not automated directly from the installation program. The average load time in a schoollab environment with remote computers must also stay acceptable...
Of course it's up to Frank to decide what to do with this possibility.
Marco
The "clear and evident syntax of DOS commands" begin to work now
As far as I tested this, it's working perfect , although creating the shortcuts remain a manual action and is still not automated directly from the installation program. The average load time in a schoollab environment with remote computers must also stay acceptable...
Of course it's up to Frank to decide what to do with this possibility.
Marco
Marco Klunder
email: marco.klunder@xs4all.nl
Windows10 PD 3.0 GHz, 2 GB of RAM, Nvidia GeForce 6700 XL
Celestia161 / SVN + Lua Edu Tools v1.2 Beta9, Celestia160-ED and Celestia1621
email: marco.klunder@xs4all.nl
Windows10 PD 3.0 GHz, 2 GB of RAM, Nvidia GeForce 6700 XL
Celestia161 / SVN + Lua Edu Tools v1.2 Beta9, Celestia160-ED and Celestia1621
-
Topic authorfsgregs
- Posts: 1307
- Joined: 07.10.2002
- With us: 22 years 1 month
- Location: Manassas, VA
Re: Problem using custom Windows shortcuts in Celestia education
Joel, and Marco:
I have tested the approach, and ... it is working. We are close to a good solution. I have, however, encountered a strange problem that I hope can be overcome.
First, here is what I did:
1. I installed the default version of Celestia 1.6.0 into the C:\Program Files directory (so as to keep the amount of files for this test manageable)
2. I copied celestia.cfg, and pasted the copy into the Celestia root directory, but renamed it as celestia-test.cfg (I did this so I could test out the use of the command line in the bat file).
3. I created a new sub-folder named "Activity_cels. in the root directory.
4. I created a bat file named "test.bat" with the following text, and placed it into the "Activity_cels" sub-folder.
5. I clicked on that test.bat file. It launched Celestia (1.6.0) just fine with no problems, using celestia-test.cfg.
6. I next created a new sub-folder named "Educational-Activities" and placed it in the Celestia root directory also.
7. I created a very simple MS Word document named "Test.doc" (to mimic the use of an Educational Activity document), and I placed it into the "Educational-Activities" sub-folder. The text of the test document is:
The "HERE" in this simple document is a hyperlink identical to what is used in my regular Educational Activities. I linked it directly to the "test.bat" file in the Activity_cels sub-folder of Celestia.
8. I opened that MS Word test document, I clicked on the word, "HERE", and it activated the bat file, launching Celestia. GREAT!
9. I created a shortcut to the "Educational-Activities" sub-folder, and placed it on the desktop. Clicking it opened the sub-folder, so that the "Test.doc" was visible and available to open.
So far ... so good!!!
I then created an Inno Installer Windows installer file which packaged up everything. I then took that file and installed it onto another computer, in another location (C:\Test Directory\Celestia-test). The bat file still worked fine and the "HERE" link in Test.doc found the bat file and also worked great. I was even able to use Inno Installer directly, to place a new dynamic shortcut to the "Educational-Activities" folder onto the new computer's desktop at the time of installation, and it worked. It opened the Educational-Activities sub-folder fine, and I was able to open "Test.doc"
Everything so far looked GREAT! This really does solve my original problem. I am very grateful for this solution.
Then, I hit the problem. It is very reproducible. If I open the Activity-Cels sub-folder and click on test.bat directly to launch Celestia, Celestia launches fine. If I then close Celestia, and click on the bat file again, Celestia opens again. It works each time I do it. However, when I open Test.doc and click on the hyperlink to open the test.bat file, Celestia opens fine the first time, but if I close Celestia and click on the "HERE" hyperlink a 2nd time, I get an immediate error message saying that "Windows cannot find celestia.exe". The program fails to open.
If I close Test.doc, however, then reopen it and click on "HERE", the bat file executes fine once more, and Celestia opens. Close Celestia and try clicking the HERE hyperlink a 2nd time, and the error message reappears. It seems that the bat file works only once when accessed from the hyperlink in the MS Word document. Then, the MS Word document has to be closed and reopened (as if it has to reset something), in order for the hyperlink to successfully activate the bat file again.
Please try this out to see if you can reproduce it. Create a simple MS Word document with the above text, create the HERE hyperlink linked to the bat file, open the test document, click on the hyperlink and see if Celestia opens. It should. Then, close Celestia but do not close Test.doc. Now ... click on HERE again, and see if you get the same error message I am getting. If so, can you figure out why this is happening?
Thanks
Frank
I have tested the approach, and ... it is working. We are close to a good solution. I have, however, encountered a strange problem that I hope can be overcome.
First, here is what I did:
1. I installed the default version of Celestia 1.6.0 into the C:\Program Files directory (so as to keep the amount of files for this test manageable)
2. I copied celestia.cfg, and pasted the copy into the Celestia root directory, but renamed it as celestia-test.cfg (I did this so I could test out the use of the command line in the bat file).
3. I created a new sub-folder named "Activity_cels. in the root directory.
4. I created a bat file named "test.bat" with the following text, and placed it into the "Activity_cels" sub-folder.
@echo off
echo searching for Celestia-ED
echo wait a moment...
for %%i in (%~d0) do set letter=%%i
for %%i in (%~p0) do set chemin=%%i
%letter%
cd %chemin%
cd ..
start Celestia.exe --conf celestia-test.cfg
5. I clicked on that test.bat file. It launched Celestia (1.6.0) just fine with no problems, using celestia-test.cfg.
6. I next created a new sub-folder named "Educational-Activities" and placed it in the Celestia root directory also.
7. I created a very simple MS Word document named "Test.doc" (to mimic the use of an Educational Activity document), and I placed it into the "Educational-Activities" sub-folder. The text of the test document is:
To begin this test, left-click HERE just once,
and wait for Celestia to open.
The "HERE" in this simple document is a hyperlink identical to what is used in my regular Educational Activities. I linked it directly to the "test.bat" file in the Activity_cels sub-folder of Celestia.
8. I opened that MS Word test document, I clicked on the word, "HERE", and it activated the bat file, launching Celestia. GREAT!
9. I created a shortcut to the "Educational-Activities" sub-folder, and placed it on the desktop. Clicking it opened the sub-folder, so that the "Test.doc" was visible and available to open.
So far ... so good!!!
I then created an Inno Installer Windows installer file which packaged up everything. I then took that file and installed it onto another computer, in another location (C:\Test Directory\Celestia-test). The bat file still worked fine and the "HERE" link in Test.doc found the bat file and also worked great. I was even able to use Inno Installer directly, to place a new dynamic shortcut to the "Educational-Activities" folder onto the new computer's desktop at the time of installation, and it worked. It opened the Educational-Activities sub-folder fine, and I was able to open "Test.doc"
Everything so far looked GREAT! This really does solve my original problem. I am very grateful for this solution.
Then, I hit the problem. It is very reproducible. If I open the Activity-Cels sub-folder and click on test.bat directly to launch Celestia, Celestia launches fine. If I then close Celestia, and click on the bat file again, Celestia opens again. It works each time I do it. However, when I open Test.doc and click on the hyperlink to open the test.bat file, Celestia opens fine the first time, but if I close Celestia and click on the "HERE" hyperlink a 2nd time, I get an immediate error message saying that "Windows cannot find celestia.exe". The program fails to open.
If I close Test.doc, however, then reopen it and click on "HERE", the bat file executes fine once more, and Celestia opens. Close Celestia and try clicking the HERE hyperlink a 2nd time, and the error message reappears. It seems that the bat file works only once when accessed from the hyperlink in the MS Word document. Then, the MS Word document has to be closed and reopened (as if it has to reset something), in order for the hyperlink to successfully activate the bat file again.
Please try this out to see if you can reproduce it. Create a simple MS Word document with the above text, create the HERE hyperlink linked to the bat file, open the test document, click on the hyperlink and see if Celestia opens. It should. Then, close Celestia but do not close Test.doc. Now ... click on HERE again, and see if you get the same error message I am getting. If so, can you figure out why this is happening?
Thanks
Frank
Re: Problem using custom Windows shortcuts in Celestia education
Hello,
Try this
The difference is ("%~p0") instead of (%~p0)
Although it is very clear and evident do not try to do the same modification on the line above.
Try this
Code: Select all
@echo off
echo searching for Celestia-ED
echo wait a moment...
for %%i in (%~d0) do set celDrive=%%i
for %%i in ("%~p0") do set selPath=%%i
%celDrive%
cd %celPath%
cd ..
start celestia160-ED.exe --conf Activity4-160.cfg
The difference is ("%~p0") instead of (%~p0)
Although it is very clear and evident do not try to do the same modification on the line above.
-
Topic authorfsgregs
- Posts: 1307
- Joined: 07.10.2002
- With us: 22 years 1 month
- Location: Manassas, VA
Re: Problem using custom Windows shortcuts in Celestia education
Jogad:
Thanks for the quick reply. Unfortunately, the fix above did not work. Celestia launches perfectly if I click the bat file directly, then close Celestia, then click the bat file again, etc. Celestia launches over and over. However, if I click the hyperlink in the MS Word document that links to the bat file, Celestia launches once fine, but if I close the program and click the "HERE" link again, I get an error message. Here is a screenshot of the error message:
Notice that the DOS black screen address is NOT what it should be. Somehow, by clicking the MS document hyperlink a second time, the bat file starts looking for celestia.exe in Program Files\My Documents??? Obviously, since it can't find it there, it gives the error message.
Is this also happening to you when you use a test document to hyperlink to the bat file?
Any other ideas?
Frank
Thanks for the quick reply. Unfortunately, the fix above did not work. Celestia launches perfectly if I click the bat file directly, then close Celestia, then click the bat file again, etc. Celestia launches over and over. However, if I click the hyperlink in the MS Word document that links to the bat file, Celestia launches once fine, but if I close the program and click the "HERE" link again, I get an error message. Here is a screenshot of the error message:
Notice that the DOS black screen address is NOT what it should be. Somehow, by clicking the MS document hyperlink a second time, the bat file starts looking for celestia.exe in Program Files\My Documents??? Obviously, since it can't find it there, it gives the error message.
Is this also happening to you when you use a test document to hyperlink to the bat file?
Any other ideas?
Frank
- Marco Klunder
- Posts: 181
- Joined: 20.02.2008
- Age: 62
- With us: 16 years 9 months
- Location: The Netherlands
Re: Problem using custom Windows shortcuts in Celestia education
Does this mean that my remark:fsgregs wrote:I was even able to use Inno Installer directly, to place a new dynamic shortcut to the "Educational-Activities" folder onto the new computer's desktop at the time of installation, and it worked. It opened the Educational-Activities sub-folder fine, and I was able to open "Test.doc"Frank
is solved? If yes, that should be greatMarco Klunder wrote:, although creating the shortcuts remain a manual action and is still not automated directly from the installation program.
Unfortunately, I do not manage to reproduce this problem here:?fsgregs wrote:Then, I hit the problem. It is very reproducible. ... However, when I open Test.doc and click on the hyperlink to open the test.bat file, Celestia opens fine the first time, but if I close Celestia and click on the "HERE" hyperlink a 2nd time, I get an immediate error message saying that "Windows cannot find celestia.exe". The program fails to open.
Frank
Jo?l, you came with an alternative clear and evident piece of DOS code Does that mean you could reproduce the problem?
I was even more confused when I tested this new code I WAS able to exactly reproduce Franks problem now
So what makes this strange behaviour happen
Marco
Marco Klunder
email: marco.klunder@xs4all.nl
Windows10 PD 3.0 GHz, 2 GB of RAM, Nvidia GeForce 6700 XL
Celestia161 / SVN + Lua Edu Tools v1.2 Beta9, Celestia160-ED and Celestia1621
email: marco.klunder@xs4all.nl
Windows10 PD 3.0 GHz, 2 GB of RAM, Nvidia GeForce 6700 XL
Celestia161 / SVN + Lua Edu Tools v1.2 Beta9, Celestia160-ED and Celestia1621
Re: Problem using custom Windows shortcuts in Celestia education
Oh
I have tested the new code on Frank's example and it worked fine for me!
The fix I have done corrects the problem of a path with a space character in it like "program files"
I must investigate a bit more.
Give me the exact position (drive, files and shortcuts) of the different elements you are using and if they are on a network or not
And comment (or remove) the first line (@echo off ) to have more informations on the screenshots.
I have tested the new code on Frank's example and it worked fine for me!
The fix I have done corrects the problem of a path with a space character in it like "program files"
I must investigate a bit more.
Give me the exact position (drive, files and shortcuts) of the different elements you are using and if they are on a network or not
And comment (or remove) the first line (@echo off ) to have more informations on the screenshots.
- Marco Klunder
- Posts: 181
- Joined: 20.02.2008
- Age: 62
- With us: 16 years 9 months
- Location: The Netherlands
Re: Problem using custom Windows shortcuts in Celestia education
@Jo?l
Celestia in my configuration resides in
I must say I've some very weird results now.
When changing back from the 2nd to the 1st solution that worked fine with me before, I also got the error there.
Until I decides to fully cut/past your 1st solution again from the forum here into the Activity4.bat (to possibly circumvent unseen typos), it worked again.
Continuing testing and trying to find out what happens, I even succeeded to reproduce the error on initial startup (unlike Frank's example with the 2nd startup)
Open Word Activity document and scroll to link
Befor clicking, goto this forum and I just selected your piece of code and pressed the [Ctrl+C] keys
Then go back to the word document an clicking the link, resulted in this error (first ECHO line removed), when using the 1st solution
Then I implemented the 2nd piece of ... code with the double quotes.
Open Word Activity document and scroll to link
Click link and Celestia starts OK
Stop Celestia, goto Word Activity document and click link for the 2nd time, resulting in this error:
So it's probably clear now, there resides some unpredictable problem behind these as easy as beautiful potential solutions
Marco
Celestia in my configuration resides in
- D:\Backup_Celestia160-ED
I must say I've some very weird results now.
When changing back from the 2nd to the 1st solution that worked fine with me before, I also got the error there.
Until I decides to fully cut/past your 1st solution again from the forum here into the Activity4.bat (to possibly circumvent unseen typos), it worked again.
Continuing testing and trying to find out what happens, I even succeeded to reproduce the error on initial startup (unlike Frank's example with the 2nd startup)
Open Word Activity document and scroll to link
Befor clicking, goto this forum and I just selected your piece of code and pressed the [Ctrl+C] keys
Then go back to the word document an clicking the link, resulted in this error (first ECHO line removed), when using the 1st solution
Then I implemented the 2nd piece of ... code with the double quotes.
Open Word Activity document and scroll to link
Click link and Celestia starts OK
Stop Celestia, goto Word Activity document and click link for the 2nd time, resulting in this error:
So it's probably clear now, there resides some unpredictable problem behind these as easy as beautiful potential solutions
Marco
Marco Klunder
email: marco.klunder@xs4all.nl
Windows10 PD 3.0 GHz, 2 GB of RAM, Nvidia GeForce 6700 XL
Celestia161 / SVN + Lua Edu Tools v1.2 Beta9, Celestia160-ED and Celestia1621
email: marco.klunder@xs4all.nl
Windows10 PD 3.0 GHz, 2 GB of RAM, Nvidia GeForce 6700 XL
Celestia161 / SVN + Lua Edu Tools v1.2 Beta9, Celestia160-ED and Celestia1621
Re: Problem using custom Windows shortcuts in Celestia education
Sorry
This is the good (for the moment) piece of code
Trying to make things clearer and more evident I have changed the name of the variable "chemin" (wich is French) into celPath (wich is nothing) and I typed selPath the first time and celPath the second time
Does this solve this problem
This is the good (for the moment) piece of code
Code: Select all
@echo off
echo searching for Celestia-ED
echo wait a moment...
for %%i in (%~d0) do set celDrive=%%i
for %%i in ("%~p0") do set celPath=%%i
%celDrive%
cd %celPath%
cd ..
start celestia160-ED.exe --conf Activity4-160.cfg
Trying to make things clearer and more evident I have changed the name of the variable "chemin" (wich is French) into celPath (wich is nothing) and I typed selPath the first time and celPath the second time
Does this solve this problem
Re: Problem using custom Windows shortcuts in Celestia education
So it's probably clear now, there resides some unpredictable problem behind these as easy as beautiful potential solutions
No! Problems are clearly identified.
Version without quotes worked well for Marco because there is no space in D:\Backup_Celestia160-ED
For Frank, that failed because of the space in "c:\program files\celestia"
The real error is that the bad script works sometimes. This is not so strange because we are working around the same directories and the actual working directory has a good chance to be the right one.
And now, with the corrected typo in the last version all should be ok.
Alas this is not the case.
I have a similar problem when I launch celestia from the hyperlink of the doc file if celestia resides on a network drive.
This seem to be because the batch file has trouble to find a drive letter when launched from the network.
I have not yet a solution for that, but if it is important I can search further.
Ideas?
-
Topic authorfsgregs
- Posts: 1307
- Joined: 07.10.2002
- With us: 22 years 1 month
- Location: Manassas, VA
Re: Problem using custom Windows shortcuts in Celestia education
Jogad:
IT WORKS!!!! Your latest bat code fix works. I no longer get any error messages when clicking on the hyperlink in the Activity documents. Marco, has this fixed this for you also?
Now, all I have to do is test this out with a full trial, loading the complete Celestia160-ED package onto another computer using bat files instead of Windows shortcuts. I suspect everything will do just fine. Joel, I cannot thank you enough for this elegant solution. Marco, I owe you a real debt of gratitude for the effort you have put into this problem as well.
Marco, because I no longer need to create all those many shortcuts with command lines in them, I can indeed instruct my Inno Installer script file to create a single desktop shortcut directly to the Educational-Activities sub-folder, at the time of installation. The script tells the installer file to create the shortcut after installation is finished, so it makes no difference where on a user PC the program has been installed. The shortcut is dynamic and will always point to the Educational-Activities folder, and will always be able to locate and launch the Activity documents.
Likewise, I have found that the hyperlinks inside the actual activity documents, which now hyperlink to the bat files in the Activity_cels sub-folder, also appear to be relative. They change and are able to locate the bat files, no matter which drive Celestia-ED is installed onto.
Unless something goes wrong in my final test, it looks like this elegant solution is indeed, exactly what I needed.
Thank you again guys. I will make one final post when I have installed a complete Celestia160-ED package onto a remote computer with a different drive letter.
Frank
P.S - Joel, if have any free time, perhaps you can explain what those few lines of code in the bat file actually do? I know NOTHING about DOS coding, but I would like to understand how that BAT file is working?
IT WORKS!!!! Your latest bat code fix works. I no longer get any error messages when clicking on the hyperlink in the Activity documents. Marco, has this fixed this for you also?
Now, all I have to do is test this out with a full trial, loading the complete Celestia160-ED package onto another computer using bat files instead of Windows shortcuts. I suspect everything will do just fine. Joel, I cannot thank you enough for this elegant solution. Marco, I owe you a real debt of gratitude for the effort you have put into this problem as well.
Marco, because I no longer need to create all those many shortcuts with command lines in them, I can indeed instruct my Inno Installer script file to create a single desktop shortcut directly to the Educational-Activities sub-folder, at the time of installation. The script tells the installer file to create the shortcut after installation is finished, so it makes no difference where on a user PC the program has been installed. The shortcut is dynamic and will always point to the Educational-Activities folder, and will always be able to locate and launch the Activity documents.
Likewise, I have found that the hyperlinks inside the actual activity documents, which now hyperlink to the bat files in the Activity_cels sub-folder, also appear to be relative. They change and are able to locate the bat files, no matter which drive Celestia-ED is installed onto.
Unless something goes wrong in my final test, it looks like this elegant solution is indeed, exactly what I needed.
Thank you again guys. I will make one final post when I have installed a complete Celestia160-ED package onto a remote computer with a different drive letter.
Frank
P.S - Joel, if have any free time, perhaps you can explain what those few lines of code in the bat file actually do? I know NOTHING about DOS coding, but I would like to understand how that BAT file is working?
- Marco Klunder
- Posts: 181
- Joined: 20.02.2008
- Age: 62
- With us: 16 years 9 months
- Location: The Netherlands
Re: Problem using custom Windows shortcuts in Celestia education
Jo?l, GREAT WORK
The described bug exactly represent the strange behaviour I experienced yesterday.
As far as I can test the new clear and evident piece of DOS code here (with/without space in dirname, on the D: and on the N: (network) drive), no problem found so far
I hope meanwhile Frank also does well in his final test with the complete Celestia160-ED package.
BUT:
@Frank:
First of all I hope your final test will do OK.
Concerning the above quote of Jo?l, I advise you to also test the solution in a network test environment in your schoollab.
If all goes well and you decide to implement it definitely, please let me know the following:
1) When do you plan to release it, so I can adjust the Dutch Activities also in time.
2) Did you meanwhile also made other Activity changes? If so, please let me know, so I can also adjust the Dutch Activities on these points on forehand.
I hope I'm not walking in front of the music here
Awaiting all positive test results, Marco
The described bug exactly represent the strange behaviour I experienced yesterday.
As far as I can test the new clear and evident piece of DOS code here (with/without space in dirname, on the D: and on the N: (network) drive), no problem found so far
I hope meanwhile Frank also does well in his final test with the complete Celestia160-ED package.
BUT:
I could not reproduce that on my network drive. How well are you doing investigating that issue? How can I help/simulate your situation here?jogad wrote:I have a similar problem when I launch celestia from the hyperlink of the doc file if celestia resides on a network drive.
This seem to be because the batch file has trouble to find a drive letter when launched from the network.
@Frank:
First of all I hope your final test will do OK.
Concerning the above quote of Jo?l, I advise you to also test the solution in a network test environment in your schoollab.
If all goes well and you decide to implement it definitely, please let me know the following:
1) When do you plan to release it, so I can adjust the Dutch Activities also in time.
2) Did you meanwhile also made other Activity changes? If so, please let me know, so I can also adjust the Dutch Activities on these points on forehand.
I hope I'm not walking in front of the music here
Awaiting all positive test results, Marco
Marco Klunder
email: marco.klunder@xs4all.nl
Windows10 PD 3.0 GHz, 2 GB of RAM, Nvidia GeForce 6700 XL
Celestia161 / SVN + Lua Edu Tools v1.2 Beta9, Celestia160-ED and Celestia1621
email: marco.klunder@xs4all.nl
Windows10 PD 3.0 GHz, 2 GB of RAM, Nvidia GeForce 6700 XL
Celestia161 / SVN + Lua Edu Tools v1.2 Beta9, Celestia160-ED and Celestia1621
Re: Problem using custom Windows shortcuts in Celestia education
Of course when I said "clear and evident" about the DOS sytaxe, it was heavily ironicfsgregs wrote:I would like to understand how that BAT file is working?
The idea is to retrieve the name of the script file wich resides in %0
The utilisation of the FOR commande is a workaround to get the path of the script in celPath and the drive letter in celDrive with this funny syntax : (%~d0%) and ("%~p0%")
Then I uses theses variables to change drive and directory to reach the directory Celestia.
START launches celestia.
But as I suspected before, this doesn't work well when Celestia is on a remote network drive.
The result is that the batch script has trouble to find the correct drive and path when lauched from the hyperlink of MSWord.Marco Klunder wrote:I could not reproduce that on my network drive.
Reproducing the problem may depend on your system but tracking the variables (with the echo command) shows that this is the fault of MSWord that uses the UNC name instead of the drive:\directory name and resets the path to the defaut user's document folder!
- this may depend of the version of MSWord
- Maybe the kind of network has its importance: my computeur is running XP while the remote computer is running Windows 7.
Generally that works fine the first time because clicking on the document sets the correct drive. But not so fine: some locations are wrong and the delay to find the drive is longer as it should.
Now close Celestia and try to launch it again from your still open document. That fails! (at least for me)
So I give up with BAT files.
Instead I use a vbs script wich is designed to handle both naming conventions.
A vbs script is natively supported by windows and its use is the same that a bat file.
And VBS syntax is really much more understandable.
This is the "definitive" working solution of the day.
Code: Select all
set Shell = WScript.CreateObject("WScript.Shell")
set fso = CreateObject("Scripting.FileSystemObject")
ScriptName = WScript.ScriptFullName
scriptPath = fso.getParentFoldername(ScriptName)
celestiaPath = fso.getParentFoldername(scriptPath)
Shell.CurrentDirectory = celestiaPath
Shell.run "celestia160-ed.exe --conf Activity4-160.cfg"
I found this code much more elegant and straightforward than the precedent.
And moreover its functions are designed to do the desired job and are not hazardous workarounds.
Simply use it by saving it with a .vbs extension instead a .bat extension.
And replace the .bat extension by .vbs in the MSWord hyperlinks.
- Marco Klunder
- Posts: 181
- Joined: 20.02.2008
- Age: 62
- With us: 16 years 9 months
- Location: The Netherlands
Re: Problem using custom Windows shortcuts in Celestia education
Jo?l, Great work again, however less "clear and evident" this time
The .VBS alternative works fine here (did not knew about its existance...).
I even succeeded to lauch Celestia from the network drive, and after that, parallel a 2nd session from the D: drive, despite Frank's warnings to only click ONCE on the hyperlink
So, as far as I am asked here, this gets my blessing
Marco
The .VBS alternative works fine here (did not knew about its existance...).
I even succeeded to lauch Celestia from the network drive, and after that, parallel a 2nd session from the D: drive, despite Frank's warnings to only click ONCE on the hyperlink
So, as far as I am asked here, this gets my blessing
Marco
Marco Klunder
email: marco.klunder@xs4all.nl
Windows10 PD 3.0 GHz, 2 GB of RAM, Nvidia GeForce 6700 XL
Celestia161 / SVN + Lua Edu Tools v1.2 Beta9, Celestia160-ED and Celestia1621
email: marco.klunder@xs4all.nl
Windows10 PD 3.0 GHz, 2 GB of RAM, Nvidia GeForce 6700 XL
Celestia161 / SVN + Lua Edu Tools v1.2 Beta9, Celestia160-ED and Celestia1621