0
votes

Am writing a script which creates a directory but when i tried (Ruby script running on windows)

destination = "path to the folder"

FileUtils.mkdir_p destination

it gives me an error saying Permission Denied (Errno::EACCES) at mkdir_p

Any help is appreciated . Thank you

1
Well … do you have the required permissions? - Jörg W Mittag
Yes, I have given all the permissions , i redone everything from scratch but still that issue persists, looks like that has something to do with the code and how am writing but am not sure - meher

1 Answers

2
votes

open your cmd terminal with administrator privileges, and then run the script again. It seems like your folder is in a place that need admin privileges, so you can create it. Also add it to your script:

require 'win32ole'

shell = WIN32OLE.new('Shell.Application')
shell.ShellExecute('path_to_ruby_program', nil, nil, 'runas')

And see this two questions:

Run ruby script in elevated mode

Detect if running with administrator privileges under Windows XP