run batch file from ruby as admistrator

run batch file from ruby as admistrator

Postby simonstaton » Wed Jun 23, 2010 2:10 pm

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
0

simonstaton 
 

Re: run batch file from ruby as admistrator

Postby Dan Rathbun » Wed Jun 23, 2010 2:23 pm

simonstaton wrote: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 :lol:
0
    I'm not here much anymore. But a PM will fire email notifications.
    User avatar
    Dan Rathbun 
    PluginStore Author
    PluginStore Author
     

    Re: run batch file from ruby as admistrator

    Postby simonstaton » Wed Jun 23, 2010 2:29 pm

    hmm so there is no way of doing this? I have updated my script with the following:
    Code: Select all
    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
    0

    simonstaton 
     

    Re: run batch file from ruby as admistrator

    Postby Dan Rathbun » Wed Jun 23, 2010 2:32 pm

    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:
    runas /?
    for parameter information.

    For more info, do a search at MSDN
    0
      I'm not here much anymore. But a PM will fire email notifications.
      User avatar
      Dan Rathbun 
      PluginStore Author
      PluginStore Author
       

      Re: run batch file from ruby as admistrator

      Postby simonstaton » Wed Jun 23, 2010 2:34 pm

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

      simonstaton 
       

      Re: run batch file from ruby as admistrator

      Postby Dan Rathbun » Wed Jun 23, 2010 2:40 pm

      simonstaton wrote: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... :roll:
      0
        I'm not here much anymore. But a PM will fire email notifications.
        User avatar
        Dan Rathbun 
        PluginStore Author
        PluginStore Author
         

        Re: run batch file from ruby as admistrator

        Postby simonstaton » Wed Jun 23, 2010 2:49 pm

        yes I know, but that easiest solution slipped through my hands :shock:
        0

        simonstaton 
         

        SketchUcation One-Liner Adverts

        by Ad Machine » 5 minutes ago



        Ad Machine 
        Robot
         



         

        Return to Developers' Forum

        Who is online

        Users browsing this forum: No registered users and 4 guests

        Visit our sponsors: