Have ruby scripts running on Windows and I’m having an issue with
mapping network drives. Yes, I need to do this with Ruby for a couple
No matter what my method or syntax is, I always get an error that the
network name can not be found. I’ve quadruple checked spelling and I
can manually browse and map the path in my script. But running the
script it says it can’t find the path. Here is some code I tried:
net = WIN32OLE.new(‘WScript.Network’)
user_name = ‘some_user_name’
password = ‘top-secret-password’
net.MapNetworkDrive( ‘X:’, ‘\server\share’, nil, user_name, password )
OLE error code:80070043 in WSHNetwork.MapNetworkDrive
The network name cannot be found.
HRESULT error code:0x80020009
from test.rb:7:in `’
If I use back ticks and enclose the command, I get a System 87 error
which is Windows telling me it can’t find the path.
Any idea what is going on? Or is there better syntax I can be using?