meher
meher

Reputation: 49

Ruby -FileUtils creating a directory ,permission denied issue on windows

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

Upvotes: 0

Views: 1058

Answers (1)

developer_hatch
developer_hatch

Reputation: 16224

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

Upvotes: 2

Related Questions