FileCreate dir fails on network drive
#1
Posted 13 January 2011 - 02:00 PM
I tried using FileCreateDir on a network drive, and it fails with Errorlevel 1. Autohotkey_L (Unicode, both 32 and 64 bit) is running with admin permissions and I can create a directory there using windows explorer.
#2
Posted 13 January 2011 - 03:39 PM
\\192.168.1.1\Shared
\\Host_Name\Shared
#3
Posted 13 January 2011 - 05:42 PM
#4
Posted 13 January 2011 - 06:06 PM
I suspect this is a known issue...
I believe you're right:
Revision 55 - August 19, 2010
. . .
Excludes FileCopyDir, FileRecycle, FileMoveDir, FileRemoveDir, FileRecycleEmpty, FileCreateDir and FileInstall as the APIs used do not consistently set or return a Win32 error code.
#5
Posted 13 January 2011 - 06:09 PM
#6
Posted 13 January 2011 - 06:23 PM
#7
Posted 13 January 2011 - 06:40 PM
DllCall("CreateDirectoryW","Str","W:\this\directory\test")
#8
Posted 13 January 2011 - 09:31 PM
#9
Posted 13 January 2011 - 10:07 PM
FYI, CreateDirectory has two parameters. Calling it directly only bypasses the check to see if the directory already exists and the recursive creation of parent directories. (CreateDirectory does not need to succeed for the parent directories, only for the final path.) FileCreateDir has the following failure points:
[*:26m65oec]DirName is empty.
[*:26m65oec]DirName already exists and does not have the "directory" attribute. FileExist(DirName) should not return "D" in that case.
[*:26m65oec]DirName is longer than MAX_PATH (260).
[*:26m65oec]CreateDirectory fails.
#10
Posted 13 January 2011 - 10:14 PM
FYI, CreateDirectory has two parameters.
Yeah I noticed that when I was reading on how to use the function but was unsure of how to use that parameter. Since it was optional in this case anyway and I knew what to expect as far as the check was concerned I just bypassed it.
#11
Posted 13 January 2011 - 10:42 PM
#12
Posted 14 January 2011 - 12:12 AM
You must pass a value for each parameter, otherwise it will use whatever garbage happens to be on the call stack. In this case, "optional" means you can pass a NULL (zero) value, which is exactly what FileCreateDir does.Since it was optional in this case anyway ...
#13
Posted 14 January 2011 - 09:34 AM
I also found this topic: <!-- m -->http://www.eggheadca... ... twork.aspx<!-- m -->
Edit: And this: <!-- m -->http://thedailyrevie... ... -102235068<!-- m -->
All topics seem to point to a permission issue.
Edit2: I just tried running it as non-admin and it worked. So it appears that it needs to be executed with the user account that is used to map the network drive. Can anyone think of a way to do this with a script running as admin?
#14
Posted 10 February 2011 - 01:26 PM
Question: Does the admin account in question have create directory permissions on the network location?
And also: Does the admin account in question have the same drive map setup? Or was the drive mapped under the normal account?
It sounds to me like the drive was mapped under the user account and when you run-as admin the admin account doesn't know that drive exists (because it was not setup for the admin).
Does any of that make any sence?
#15
Posted 10 February 2011 - 02:48 PM




