sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Run batch file from ruby as admistrator

    Scheduled Pinned Locked Moved Developers' Forum
    7 Posts 2 Posters 4.0k Views 2 Watching
    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.
    • 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

      1 Reply Last reply 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.

        1 Reply Last reply 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

          1 Reply Last reply 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.

            1 Reply Last reply Reply Quote 0
            • S Offline
              simonstaton
              last edited by

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

              1 Reply Last reply 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.

                1 Reply Last reply Reply Quote 0
                • S Offline
                  simonstaton
                  last edited by

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

                  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