sketchucation logo sketchucation
    • Login
    πŸ›£οΈ Road Profile Builder | Generate roads, curbs and pavements easily Download

    Run batch file from ruby as admistrator

    scheduled pinned locked moved Developers' Forum
    7 Posts 2 Posters 4.1k Views 2 Watching
    loading-more-posts
    • oldest-to-newest
    • newest-to-oldest
    • most-votes
    reply
    • reply-as-topic
    guest-login-reply
    deleted-message
    • S Offline
      simonstaton
      last edited by

      Hi,

      I am running a batch file from ruby using:
      ge=UI.openURL(Sketchup.find_support_file('')+"/registergoogleearthcmd.cmd")

      inside the batch file is the following:
      "C:\Users\Simon\Documents\Action Design Your Own v2\Action 3D\client\googleearth.exe" /regserver

      however when I run sketchup and the batch file is loaded it says it needs to be run as administrator now this command works fine if I load up cmd as admin and manually typing it in it goes straight through.

      So my question is how can I run this from ruby as an administrator?

      Simon

      one-reply-to-this-post last-reply-time reply quote 0
      • Dan RathbunD Offline
        Dan Rathbun
        last edited by

        @simonstaton said:

        So my question is how can I run this from ruby as an administrator?

        What would be the point of having an Operating System Security if any script was allowed to run with Administrative Rights?

        Oh wait... I do remember MS-DOS πŸ˜†

        I'm not here much anymore.

        one-reply-to-this-post last-reply-time reply quote 0
        • S Offline
          simonstaton
          last edited by

          hmm so there is no way of doing this? I have updated my script with the following:

          tmp_cmd="My_tmp_file_"+Time.now.to_i.to_s+".cmd"
          cmd_path="C;/Temp/"+tmp_cmd
          cmd_line="\""+Sketchup.find_support_file('')+"/client/googleearth.exe\" /regserver\nexit"
          cmd=File.new(cmd_path, "w")
          cmd.puts(cmd_line)
          cmd.close
          UI.openURL(cmd_path)
          sleep(1)
          File.delete(cmd_path)
          

          if I cant run as admin is there any other way or registering google earths location outside of its default through command line or ruby?

          Simon

          one-reply-to-this-post last-reply-time reply quote 0
          • Dan RathbunD Offline
            Dan Rathbun
            last edited by

            You'd need to use the runas.exe utility.
            It's in the Windows/system32 folder, so is available in the PATH.

            Open a CMD window, and type:
            %(#004000)[**runas /?**]
            for parameter information.

            For more info, do a search at MSDN

            I'm not here much anymore.

            one-reply-to-this-post last-reply-time reply quote 0
            • S Offline
              simonstaton
              last edited by

              dont worry solved I just need to right click sketchup and run as administrator

              one-reply-to-this-post last-reply-time reply quote 0
              • Dan RathbunD Offline
                Dan Rathbun
                last edited by

                @simonstaton said:

                dont worry solved I just need to right click sketchup and run as administrator

                Manual? I could have told you that!

                You asked how to do it with a batchfile... πŸ˜’

                I'm not here much anymore.

                one-reply-to-this-post last-reply-time reply quote 0
                • S Offline
                  simonstaton
                  last edited by

                  yes I know, but that easiest solution slipped through my hands 😲

                  one-reply-to-this-post last-reply-time 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