how to run a external program?

Runes of Magic/Radiant Arcana (http://www.runesofmagic.com)
Post Reply
Message
Author
User avatar
botje
Posts: 656
Joined: Wed Oct 27, 2010 7:17 am

how to run a external program?

#1 Post by botje » Mon Apr 01, 2013 1:25 pm

like title, how do i run a cmdline program from the bot?

User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: how to run a external program?

#2 Post by rock5 » Mon Apr 01, 2013 1:54 pm

You can use system(cmd) or os.execute(cmd) like I did in my "login" script. http://www.solarstrike.net/phpBB3/viewt ... gin#p48107 You can check that out to see how I used os.execute to start the game client.
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan

User avatar
botje
Posts: 656
Joined: Wed Oct 27, 2010 7:17 am

Re: how to run a external program?

#3 Post by botje » Mon Apr 01, 2013 4:23 pm

Code: Select all

function MemClean(sleeptime)
	if sleeptime == nil or sleeptime == "" then sleeptime = 5000 end
	
	os.execute("start 'ramrush.exe' -AutoOptimize")
	yrest(sleeptime)
	os.execute("TASKKILL /IM ramrush.exe /F")
end
exe is in rombot folder, but cant find the program...

User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: how to run a external program?

#4 Post by lisa » Mon Apr 01, 2013 7:07 pm

Notice in Rock's example he uses getExecutionPath().

Code: Select all

	client = string.lower(client)
	local path = getExecutionPath().."/"..client
	-- fix spaces
	path = string.gsub(path," ","\" \"")
	local a,b,c = os.execute("START "..path.." NoCheckVersion")
	if not a then
		error("Trouble executing shortcut. Values returned were: "..(a or "nil")..", "..(b or "nil")..", "..(c or "nil"))
	end
from rombot the getExecutionPath() is the rom folder, you can test from commandline.

Code: Select all

Command> print(getExecutionPath())
C:/micromacro/scripts/rom
if you add that print to your userfunction you can find out for sure where it is looking for the file to start.
Remember no matter you do in life to always have a little fun while you are at it ;)

wiki here http://www.solarstrike.net/wiki/index.php?title=Manual

User avatar
botje
Posts: 656
Joined: Wed Oct 27, 2010 7:17 am

Re: how to run a external program?

#5 Post by botje » Tue Apr 02, 2013 8:18 am

thanx lisa, that did the trick ^^

Code: Select all

function MemClean(sleeptime)
	if sleeptime == nil or sleeptime == "" then sleeptime = 50000 end
	
	os.execute("start "..getExecutionPath().."/ramrush.exe -AutoOptimize")
	yrest(sleeptime)
	os.execute("TASKKILL /IM ramrush.exe /F")
end

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 2 guests