Reputation: 89
The following script is executed within Sketchup as a ruby script.
notepad = File.absolute_path("notepad.exe", "C:/Windows")
puts "fileName :"+notepad
exec((notepad))
When closing the notepad.exe windows ... it also close/quit Sketchup. How to only close notepad.exe and not Sketchup ?
Thks
Upvotes: 3
Views: 237
Reputation: 11
SketchUp's Ruby has several easy ways of starting external applications or having files open in their associated external application.
The first easy way is UI::open_url()
UI.open_url("notepad.exe")
If you want more control over how an external application opens, you can use the Windows Scripting Host via Ruby's (Windows only) WIN32OLE
class.
See the Windows Scripting Host
# Run notepad in a separate process with default window type
# and do not wait, return to SketchUp Ruby immediately.
def run_notepad
require 'win32ole' unless defined?(WIN32OLE)
WIN32OLE.new("WScript.Shell").Run("%windir%/notepad.exe")
end
Upvotes: 0
Reputation: 13719
You are using exec
to run notepad, but according to documentation exec
replaces the current process.
Try running the command using system
method instead - it executes command in a subshell
Upvotes: 2