Run batch file from ruby as admistrator
-
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" /regserverhowever 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
-
@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

-
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
-
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
-
dont worry solved I just need to right click sketchup and run as administrator
-
@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...

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

Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better π
Register LoginAdvertisement