Not sure what you want, cause you are basically giving the answer yourself already
Do you have difficulty with capturing arguments using regexp or applying them, cause applying is done the way you described, basically. Anyway, here's an example using the ping.exe file:
Regexp: ^ping (.+) (.+)
Command: C:\Windows\System32\ping.exe -n $$1 $$2
This pings a host n times, with host = $$2 and n = $$1