i am trying to change windows file association via ruby. Assoc part works but ftype does not work why it does not work?
pth = Dir.pwd
pth << "/pfReader.exe"
pth.gsub "/","\\"
system("assoc .pf=pfReader")
puts("assoc command is done \n")
system("ftype pfReader = '#{pth}' '%1'")
puts("ftype command is done \n")
A good hint to debug problems like these is to replace system
with puts
. If you do that, you will realize the problem is on this line:
pth.gsub "/","\\"
While you probably wanted this:
pth.gsub! "/","\\"
Also I'm not sure the Windows cmd.exe likes single quotes, so you probably need to fix your ftype
call also to use the proper double quotes:
system("ftype pfReader=\"#{pth}\" \"%1\"")