import sublime
import sublime_plugin
import os
import subprocess
 
class run_o(sublime_plugin.TextCommand):
	def run(self,file):
		file_to_open =self.view.file_name()
		tester = file_to_open[-4:]
		directory=sublime.packages_path()
		if (tester == '.asc' or tester == '.p3d' or tester == '.3ds' or tester == '.sda'):
			file_final=str(' \"'+file_to_open+'\" ')
			cmd = "pushd "+directory+" & cd "+directory+" & cd Bin\o  & Start /I run "+file_final
			os.system(cmd)
		else:
			cmd = "pushd "+directory+" & cd "+directory+" & cd Bin\o  & Start /I run "
			os.system(cmd)