Mapping Issues : Intranet URL as Drive Letter

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
SIMMS7400
Posts: 546
Joined: 07 Jan 2016 07:47

Mapping Issues : Intranet URL as Drive Letter

#1 Post by SIMMS7400 » 22 Jan 2018 16:50

Hi Folks –

I’m running into some strange behavior when trying to map an intranet URL to a drive letter.

For instance, variable-less command like such works fine with no issues:

Code: Select all

IF EXIST X:\ NET USE X: /delete

NET USE X: "http://tiger.client.com/organization/ccofinance/financesscandsystems/finance_systems/MDM/MDM Hierarchies" /USER:MPI\ServiceAccount Password
However, when I introduce variables instead of hard-coded strings and dynamic drive letter setting, it fails:

Code: Select all

FOR %%D IN ( b e f g h i j k l m o p q r s t u v w x y z ) DO (
	IF NOT EXIST "%%D:\" (
		SET "DL=%%D:"
		GOTO BREAK
	)
)
:BREAK

NET USE "%DL%" "%RDF_HORIZON_URL%" /USER:%SERVICEACCOUNT% >nul 2>&1  && (
	ECHO Successful : Intranet URL Mapped as Drive >>%LOGFILE%
	) || (
	ECHO Failed : Intranet URL Mapped as Drive >>%LOGFILE%
	GOTO AbnormalExit
)
pause
I also get the 1244 error message when using the above approach.
DOSTIPS.png
DOSTIPS.png (2.42 KiB) Viewed 3833 times
The reason I’m setting a specific drive letter is so I can delete it at the end and not need to parse the NET USE command to do so.

Does anyone have any ideas? Thanks!

Squashman
Expert
Posts: 4486
Joined: 23 Dec 2011 13:59

Re: Mapping Issues : Intranet URL as Drive Letter

#2 Post by Squashman » 22 Jan 2018 17:13

Thought you were working on this in a previous thread.

I answered a question similar to yours about not wanting to know the drive letter. I can't find the thread right now but will keep searching. You can actually use the NET USE command to authenticate to a source WITHOUT assigning a drive letter. You can then use the PUSHD command to access the path. Then use PUSHD to get it off of the stack. Then use NET USE to dismount the source without ever having to know what the drive letter is. I personally don't know if it will work an HTTP path. I didn't even know you could use an HTTP path with Net use.

Edit: here is the thread
Last edited by Squashman on 22 Jan 2018 17:18, edited 1 time in total.
Reason: Added Link

SIMMS7400
Posts: 546
Joined: 07 Jan 2016 07:47

Re: Mapping Issues : Intranet URL as Drive Letter

#3 Post by SIMMS7400 » 24 Jan 2018 06:08

Hi Squash -

Thank you for the link - I've been able to use PUSHD as long as I can convert the HTTP path into UNC style. However, the further I dig, it seems to be related to access from within SharePoint itself rather how the script is written. Going to dig in security a bit more and I"ll report back.

Thanks again!

Squashman
Expert
Posts: 4486
Joined: 23 Dec 2011 13:59

Re: Mapping Issues : Intranet URL as Drive Letter

#4 Post by Squashman » 24 Jan 2018 09:46

Here is your previous thread.

Post Reply