sketchucation logo sketchucation
    • Login
    🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    Cannot launch SU from hta [Now can]

    Scheduled Pinned Locked Moved Developers' Forum
    17 Posts 4 Posters 989 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • chrisglasierC Offline
      chrisglasier
      last edited by chrisglasier

      
      shell = new ActiveXObject("WScript.shell");
      shell.run("sketchup.exe");
      
      

      This works for winzip but not for sketchup (Error: The system cannot find the file specified.)

      I have tried to launch several other exes but cannot see any trend for errors.

      Does anyone know why and more importantly how to fix it.

      Thanks

      With TBA interfaces we can analyse what is to be achieved so that IT can help with automation to achieve it.

      1 Reply Last reply Reply Quote 0
      • thomthomT Offline
        thomthom
        last edited by

        You probably have to specify full path to SU.
        I'm guessing WinZip has added it's path to the environment variables...

        Thomas Thomassen — SketchUp Monkey & Coding addict
        List of my plugins and link to the CookieWare fund

        1 Reply Last reply Reply Quote 0
        • J Offline
          Jim
          last edited by

          Hello Chris,

          You need to use the full path - the HTA knows not where to find "sketchup.exe"

          shell.run("c:\program files\google\google sketchup 8\sketchup.exe");

          (You may need to double-up on the slashes.)

          But, that location is selected by the user on installation of sketchup, so may be different per user.

          You need to read the registry to get the actual path. I have a partially finished sketchup launcher I need to add this too also, so I will look at that today.

          Hi

          1 Reply Last reply Reply Quote 0
          • thomthomT Offline
            thomthom
            last edited by

            @jim said:

            You need to read the registry to get the actual path. I have a partially finished sketchup launcher I need to add this too also, so I will look at that today.

            In SU prior to SU7 I think you need to check the .skp file accommodation as there wasn't any proper registry info for this. (If I remember correctly...)

            Thomas Thomassen — SketchUp Monkey & Coding addict
            List of my plugins and link to the CookieWare fund

            1 Reply Last reply Reply Quote 0
            • J Offline
              Jim
              last edited by

              I don't know about version 5 or earlier.

              Version 6 InstallLocation:
              HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{98736A65-3C79-49EC-B7E9-A3C77774B0E6}\InstallLocation

              Version 7+ (so far)
              HKLM\SOFTWARE\Google\Google SketchUp [7|8]\InstallLocation

              And the license file for 6 is stored in the /SketchUp/Support folder, where version 7+ is in /All Users/Application Data\Google\SketchUp [version]\

              Hi

              1 Reply Last reply Reply Quote 0
              • thomthomT Offline
                thomthom
                last edited by

                @jim said:

                Can we get a full-width code style, please?

                +1

                Thomas Thomassen — SketchUp Monkey & Coding addict
                List of my plugins and link to the CookieWare fund

                1 Reply Last reply Reply Quote 0
                • J Offline
                  Jim
                  last edited by

                  This doesn't include version 6 (or prior,) but it should find the installation location for versions 7 and later.

                  <span class="syntaxdefault">version </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> </span><span class="syntaxstring">'8'</span><span class="syntaxkeyword">;<br /></span><span class="syntaxdefault">var loc</span><span class="syntaxkeyword">;<br /></span><span class="syntaxdefault">try </span><span class="syntaxkeyword">{<br /></span><span class="syntaxdefault">    loc </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> shell</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">RegRead</span><span class="syntaxkeyword">(</span><span class="syntaxstring">'HKLM\\Software\\Google\\Google SketchUp '</span><span class="syntaxkeyword">+</span><span class="syntaxdefault">version</span><span class="syntaxkeyword">+</span><span class="syntaxstring">'\\InstallLocation\\'</span><span class="syntaxkeyword">);<br />}</span><span class="syntaxdefault"> catch</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">err</span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">{<br /></span><span class="syntaxdefault">  </span><span class="syntaxcomment">//alert(err.message);<br /></span><span class="syntaxkeyword">}<br /></span><span class="syntaxcomment">// loc will be the location as a String, or undefined.<br />// need to quote the path because it contains spaces.<br /></span><span class="syntaxdefault">var cmd </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> </span><span class="syntaxstring">'"'</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">+</span><span class="syntaxdefault"> loc </span><span class="syntaxkeyword">+</span><span class="syntaxdefault"> </span><span class="syntaxstring">'\\sketchup.exe'</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">+</span><span class="syntaxdefault"> </span><span class="syntaxstring">'"'</span><span class="syntaxkeyword">;<br /></span><span class="syntaxdefault">try </span><span class="syntaxkeyword">{</span><span class="syntaxdefault"> shell</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">run</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">cmd</span><span class="syntaxkeyword">);</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">}</span><span class="syntaxdefault"> catch</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">e</span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">{</span><span class="syntaxdefault"> alert</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">e</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">message</span><span class="syntaxkeyword">);</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">}<br /></span><span class="syntaxdefault"> </span>
                  

                  Can we get a full-width code style, please?

                  Hi

                  1 Reply Last reply Reply Quote 0
                  • chrisglasierC Offline
                    chrisglasier
                    last edited by

                    @jim said:

                    Hello Chris,

                    You need to use the full path - the HTA knows not where to find "sketchup.exe"

                    You need to read the registry to get the actual path. I have a partially finished sketchup launcher I need to add this too also, so I will look at that today.

                    But it knows where to find iexplore, firefox and notepad.

                    Anyway I tried that but still no joy with or without double slashes. Also tried (blindly) adding %20 for the gaps. Can I have a copy of your launcher when finished - presumably it can launch anything and open files?

                    About full width code boxes, it seems to me, with all the code, images etc it would be better for the default to be full width with an option to "blockquote" text.

                    With TBA interfaces we can analyse what is to be achieved so that IT can help with automation to achieve it.

                    1 Reply Last reply Reply Quote 0
                    • chrisglasierC Offline
                      chrisglasier
                      last edited by

                      I just found out that this works:

                      
                      shell = new ActiveXObject("WScript.shell");
                      shell.run("file;///C;/Program%20Files/Google/Google%20SketchUp%207/SketchUp.exe");
                      
                      

                      but this doesn't:

                      
                      shell = new ActiveXObject("WScript.shell");
                      shell.run("C;/Program%20Files/Google/Google%20SketchUp%207/SketchUp.exe");
                      
                      

                      I suppose it is because the hta is a kind of browser but that doesn't explain why winzip.exe and the others work ... or does it?

                      Thanks Jim for the copy of the launcher. I understand it better now. Is it possible to get the file name by browsing. (I can't remember how).

                      Also - a follow up question - is it possible to open a webdialog on loading SU and position off screen?

                      Thanks

                      With TBA interfaces we can analyse what is to be achieved so that IT can help with automation to achieve it.

                      1 Reply Last reply Reply Quote 0
                      • thomthomT Offline
                        thomthom
                        last edited by

                        @chrisglasier said:

                        But it knows where to find iexplore, firefox and notepad.

                        @thomthom said:

                        I'm guessing WinZip has added it's path to the environment variables...

                        Paths.png

                        Thomas Thomassen — SketchUp Monkey & Coding addict
                        List of my plugins and link to the CookieWare fund

                        1 Reply Last reply Reply Quote 0
                        • Dan RathbunD Offline
                          Dan Rathbun
                          last edited by

                          @chrisglasier said:

                          Also - a follow up question - is it possible to open a webdialog on loading SU and position off screen?

                          YES .. I've done it (in an unreleased utility.) Works great.

                          I'm not here much anymore.

                          1 Reply Last reply Reply Quote 0
                          • Dan RathbunD Offline
                            Dan Rathbun
                            last edited by

                            @chrisglasier said:

                            Does anyone know why and more importantly how to fix it.

                            You could set an environment var "SUpath" to the install location and try using that in the path.

                            Ruby:
                            f = File.new('C:\setSUpath.cmd') f.print "SET SUpath="+Sketchup.find_support_file("") f.close

                            in your Js it'd be:
                            %(#8000BF)[shell.Exec("C:\setSUpath.cmd") shell.run( shell.ExpandEnvironmentStrings("%SUpath%")+"\sketchup.exe");]
                            See: [Methods (Windows Script Host)](http://msdn.microsoft.com/en-us/library/2x3w20xf(v)

                            I'm not here much anymore.

                            1 Reply Last reply Reply Quote 0
                            • chrisglasierC Offline
                              chrisglasier
                              last edited by

                              Thanks for both your notes Dan.

                              Would you tell me how to automatically open a webdialog on launching SU?

                              I should explain that I am trying to facilitate opening things from a single hta (as a prototype) with the minimum of clicks ... it could be an application, a web page, an html widget and so on. The choice would be up to the owner to set up.

                              So in terms of applications I'm thinking s/he would need to select the exe file in its directory in order to store the filename and path. I am looking at this example but are having some difficulty implementing it. If you or anyone else knows of a better way, preferably in js, please let me know.

                              Thanks again

                              With TBA interfaces we can analyse what is to be achieved so that IT can help with automation to achieve it.

                              1 Reply Last reply Reply Quote 0
                              • J Offline
                                Jim
                                last edited by

                                @chrisglasier said:

                                Would you tell me how to automatically open a webdialog on launching SU?

                                Write the method as you would normally using module as namespace.

                                Then at the end of the file, instead of creating a menu for the method, just call the method.

                                
                                
                                module CG
                                 def self.my_web_dialog
                                  # create and show the dialog
                                 end
                                end
                                
                                CG.my_web_dialog
                                
                                

                                Hi

                                1 Reply Last reply Reply Quote 0
                                • Dan RathbunD Offline
                                  Dan Rathbun
                                  last edited by

                                  @chrisglasier said:

                                  I am looking at this example but are having some difficulty implementing it. If you or anyone else knows of a better way, preferably in js, please let me know.

                                  That example is in VBS. You can use it "as is" by wrapping it within an html <SCRIPT> tag but specifying the language attribute as either "vbs" or "vbscript" See [MSDN](http://msdn.microsoft.com/en-us/library/ms533940(v).

                                  Or you can translate it into JS.

                                  • change DIM to VAR
                                  • change all blocks to { }, ie, replace End If, End Loop etc with a } and insert a { at the begining of the block.
                                    This includes wrapping all function blocks, and replace the function's END with }.
                                  • put ; (a semi-colon) at end of all statements.
                                  • There may be some other quirky things that may need to change slightly.

                                  I'm not here much anymore.

                                  1 Reply Last reply Reply Quote 0
                                  • chrisglasierC Offline
                                    chrisglasier
                                    last edited by

                                    Thanks J + D. Very helpful as usual.

                                    With TBA interfaces we can analyse what is to be achieved so that IT can help with automation to achieve it.

                                    1 Reply Last reply Reply Quote 0
                                    • chrisglasierC Offline
                                      chrisglasier
                                      last edited by

                                      Also found this written by the same guy specifically for hta's. I just wrote the input into my code so there is no need for any pop up window. Maybe useful for others ...
                                      2010-10-07_1820.png

                                      With TBA interfaces we can analyse what is to be achieved so that IT can help with automation to achieve it.

                                      1 Reply Last reply Reply Quote 0
                                      • 1 / 1
                                      • First post
                                        Last post
                                      Buy SketchPlus
                                      Buy SUbD
                                      Buy WrapR
                                      Buy eBook
                                      Buy Modelur
                                      Buy Vertex Tools
                                      Buy SketchCuisine
                                      Buy FormFonts

                                      Advertisement