Sign in to follow this  
Followers 0
BrendonKoz

DriveMapAdd; odd behavior

5 posts in this topic

I'm trying to map a drive to a network share which is already shared as a different drive. The reason for this is I want to access the specific folder/location as a different user that has different credentials on the server. To do this, instead of using server_name I'm using server_ip ... this has worked in a previous project of mine (which is still working as an executable and as a script).

The script (portion) that works is as follows:

$result = DriveMapAdd('X:', '\\10.2.1.140\Redirect\username', 0, 'DOMAIN\username', 'password');

The code that does not work (with the given drive letter NOT in use prior to run) is as follows:

$result = DriveMapAdd('X:', '\\10.2.1.140\SSPL Shares\');

I get a result of 0 with @error set to 1 and @extended set to 53, which according to http://msdn.microsoft.com/en-us/library/ms681382(v=vs.85).aspx is that the network path could not be found. When typing that path in to the Windows Run command, it opens up just fine. (Eventually I'd add the user credentials - right now I'm just trying to get it to work as is - my account is a network administrator so it can see that folder/share just fine.)

I also tried that same line of code with a folder/share/path that does not contain a space, as well as one that is only 6 characters (in case DOS filename was an issue) and it continues to give the same error...all while the first line provided above works without issue.

Does anyone have any ideas? ... DriveMapAdd seems to be more stable than using "net add" from the command line, so I'd prefer to use this function if possible.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Try this:

$result = DriveMapAdd('X:', '"\\10.2.1.140\SSPL Shares\"');

 

Worked for me, locally... (not the same IP, of course :))...if not, you can always map straight to the IP.

edit: works for me without the wrapped quotes also...odd.

Edited by jdelaney

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites

I unfortunately get an @error of 5 ("Invalid remote share") when using double quotes inside the single quotes. I've tried connecting directly to just the IP with no path, but even that isn't working (it's still providing an @extended error of 53).

I didn't think of this before, but I just upgraded my PC to Windows 8.1 Pro. Could it be that Windows 8 has a different type of permissions structure that this function does not handle? It wouldn't make too much sense as to why the ...Redirectusername works, but...just a thought.

Share this post


Link to post
Share on other sites

Do you have access to a Windows 7 pc or laptop to test the script?   also, does the trailing backslash matter on the last example?

Share this post


Link to post
Share on other sites

I didn't think about testing the script itself on a WinXP/Win7 PC (I have access to mostly WinXP), though I did test an executable from the script that was running on my personal Windows 8.1 PC and it gave the same error codes.

Aww crap...it was the trailing backslash that caused it not to work (under both WinXP and Win8). :( It didn't mention any issues with that in the help file and Explorer handled it fine so I didn't think anything of it.

I'd wonder if that could be added to the helpfile somehow? (As long as I've used AutoIT, not sure how to submit change requests to the project.)

Thanks gruntydatsun and jdelaney!!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0