John Davies
asked on
Script to Map Sharepoint Drive
I want to write a batch file that I can distribute to users that will map their sharepoint secure folder, have the UNC that will prompt them for logon name and password for sharepoint when run and when the cookie times out and the connection drops they can simply click the batch file and remap
net use i: /delete
net use i: "\\XXX.sharepoint.com@SSL/ DavWWWRoot /sites/Com mercial/Te am Secure/" USER:email address * /PERSISTENT:YES
No domain, sharepoint online
* dont want to store password, want to prompt
Any help appreciated
John
net use i: /delete
net use i: "\\XXX.sharepoint.com@SSL/
No domain, sharepoint online
* dont want to store password, want to prompt
Any help appreciated
John
ASKER
Have tried it and didn't see the mapping appear (changed the drive mapping to suit), Have copied the link and can see the shared folder. no mapping :-)
ERROR The logon and password were tests
ERROR The logon and password were tests
Please Enter your email address to authenticate with: lkij
Please Enter your Password: jhjhjh
The network connection could not be found.
More help is available by typing NET HELPMSG 2250.
The network connection could not be found.
More help is available by typing NET HELPMSG 2250.
The syntax of this command is:
NET USE
[devicename | *] [\\computername\sharename[ \volume] [password | *]]
[/USER:[domainname\]userna me]
[/USER:[dotted domain name\]username]
[/USER:[username@dotted domain name]
[/SMARTCARD]
[/SAVECRED]
[[/DELETE] | [/PERSISTENT:{YES | NO}]]
NET USE {devicename | *} [password | *] /HOME
NET USE [/PERSISTENT:{YES | NO}]
Drive Mapping Failed
Please Enter your Password: jhjhjh
The network connection could not be found.
More help is available by typing NET HELPMSG 2250.
The network connection could not be found.
More help is available by typing NET HELPMSG 2250.
The syntax of this command is:
NET USE
[devicename | *] [\\computername\sharename[
[/USER:[domainname\]userna
[/USER:[dotted domain name\]username]
[/USER:[username@dotted domain name]
[/SMARTCARD]
[/SAVECRED]
[[/DELETE] | [/PERSISTENT:{YES | NO}]]
NET USE {devicename | *} [password | *] /HOME
NET USE [/PERSISTENT:{YES | NO}]
Drive Mapping Failed
@John Davies.
The reason it didn't map correctly was most likely due to my minor syntax issue here I left the "/" off "/User:" (Oops!)
Also, I thought I posted the amended version of this code that had "/Persistent:NO"** on the command but I put it on the variable for the sharepoint path, which should have been ignored but could have caused an issue.
I have fixed both below.
(**BTW: You don't want these to be persistent, you want to re-map them each time the user logs on, otherwise they will be issues. If you do want the path to be mapped once and stick around, you might want to use a Symbolic link instead, so the remote SharePoint is mounted as a folder on the operating system instead of a drive.)
The reason it didn't map correctly was most likely due to my minor syntax issue here I left the "/" off "/User:" (Oops!)
Also, I thought I posted the amended version of this code that had "/Persistent:NO"** on the command but I put it on the variable for the sharepoint path, which should have been ignored but could have caused an issue.
I have fixed both below.
(**BTW: You don't want these to be persistent, you want to re-map them each time the user logs on, otherwise they will be issues. If you do want the path to be mapped once and stick around, you might want to use a Symbolic link instead, so the remote SharePoint is mounted as a folder on the operating system instead of a drive.)
REM Script: MapSharepoint.cmd
@(
setlocal enabledelayedexpansion
echo off
SET "_SharepointPath=\\XXX.sharepoint.com@SSL\DavWWWRoot\sites\Commercial\Team Secure"
SET "_Email="
SET "_PW="
SET "_eLvl=0"
)
CALL :Main
(
ENDLOCAL
EXIT /B %_eLvl%
)
:Main
SETLOCAL
ECHO. Mapping Folder "%_SharepointPath%"
ECHO.
SET /P "_Email=Please Enter your email address to authenticate with: "
IF NOT DEFINED _Email (
ECHO. Aborting! No Email Provided!
SET "_eLvl=1"
GOTO :EOF
)
SET /P "_PW=Please Enter your Password: "
IF NOT DEFINED _PW (
ECHO. Aborting! No Password Provided!
SET "_eLvl=2"
GOTO :EOF
)
NET USE I: /D /Y >NUL
NET USE I: /D /Y >NUL
NET USE >NUL
(
NET USE I: "%_SharepointPath%" /USER:%_Email% %_PW% /Persistent:NO
) || (
ECHO. Drive Mapping Failed!
SET "_eLvl=3"
)
(
ENDLOCAL
SET "_PW="
SET "_eLvl=%_eLvl%"
)
GOTO :EOF
ASKER
Hi Ben,
Really appreciate your help here, so close but still getting the error.
Made a change to the domain in the sharepoint link and didnt change anything else.
Pasting into browser - \\xxx.sharepoint.com@SSL\D avWWWRoot\ sites\Comm ercial\Tea m Secure - worked
Pasting into cmd - net use i: \\xxx.sharepoint.com@SSL\D avWWWRoot\ sites\Comm ercial\Tea m Secure - didnt work, handle the space in script
Run whole script
C:\Users\LAPTOP\Desktop\Ba t Files>REM Script: MapSharepoint.cmd
Mapping Folder "\\xxx.sharepoint.com@SSL\ DavWWWRoot \sites\Com mercial\"
Please Enter your email address to authenticate with: ddsbvdfgvdf@test.com
Please Enter your Password: vfadvdfb
The network connection could not be found.
More help is available by typing NET HELPMSG 2250.
The network connection could not be found.
More help is available by typing NET HELPMSG 2250.
System error 53 has occurred.
The network path was not found.
Drive Mapping Failed
Press any key to continue . . .
So it looks like the handling of the space may is causing the issue Ben, have tried the quotes :-(
Thanks Again
John
Really appreciate your help here, so close but still getting the error.
Made a change to the domain in the sharepoint link and didnt change anything else.
Pasting into browser - \\xxx.sharepoint.com@SSL\D
Pasting into cmd - net use i: \\xxx.sharepoint.com@SSL\D
Run whole script
C:\Users\LAPTOP\Desktop\Ba
Mapping Folder "\\xxx.sharepoint.com@SSL\
Please Enter your email address to authenticate with: ddsbvdfgvdf@test.com
Please Enter your Password: vfadvdfb
The network connection could not be found.
More help is available by typing NET HELPMSG 2250.
The network connection could not be found.
More help is available by typing NET HELPMSG 2250.
System error 53 has occurred.
The network path was not found.
Drive Mapping Failed
Press any key to continue . . .
So it looks like the handling of the space may is causing the issue Ben, have tried the quotes :-(
Thanks Again
John
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Yes, team secure is a valid document library. I have permissions in it, can map through browser to it via
\\xxx.sharepoint.com@SSL\D avWWWRoot\ sites\Comm ercial\Tea m Secure\
Can map a drive via
https://xxx.sharepoint.com/sites/Commercial/Team Secure/
But need to script it
Not changed any of the script other than the Sharepoint Doc Library location
REM Script: MapSharepoint.cmd
@(
setlocal enabledelayedexpansion
echo off
SET "_SharepointPath=\\xxx.sha repoint.co m@SSL\DavW WWRoot\sit es\Commerc ial\Team Secure\"
SET "_Email="
SET "_PW="
SET "_eLvl=0"
)
CALL :Main
(
ENDLOCAL
EXIT /B %_eLvl%
)
:Main
SETLOCAL
ECHO. Mapping Folder "%_SharepointPath%"
ECHO.
SET /P "_Email=Please Enter your email address to authenticate with: "
IF NOT DEFINED _Email (
ECHO. Aborting! No Email Provided!
SET "_eLvl=1"
GOTO :EOF
)
SET /P "_PW=Please Enter your Password: "
IF NOT DEFINED _PW (
ECHO. Aborting! No Password Provided!
SET "_eLvl=2"
GOTO :EOF
)
NET USE I: /D /Y >NUL
NET USE I: /D /Y >NUL
NET USE >NUL
(
NET USE I: "%_SharepointPath%" /USER:%_Email% %_PW% /Persistent:NO
) || (
ECHO. Drive Mapping Failed!
SET "_eLvl=3"
)
(
ENDLOCAL
SET "_PW="
SET "_eLvl=%_eLvl%"
)
Pause
GOTO :EOF
Trying this on my machine, signing out, removing shares, reboots etc.
Thanks
John
\\xxx.sharepoint.com@SSL\D
Can map a drive via
https://xxx.sharepoint.com/sites/Commercial/Team Secure/
But need to script it
Not changed any of the script other than the Sharepoint Doc Library location
REM Script: MapSharepoint.cmd
@(
setlocal enabledelayedexpansion
echo off
SET "_SharepointPath=\\xxx.sha
SET "_Email="
SET "_PW="
SET "_eLvl=0"
)
CALL :Main
(
ENDLOCAL
EXIT /B %_eLvl%
)
:Main
SETLOCAL
ECHO. Mapping Folder "%_SharepointPath%"
ECHO.
SET /P "_Email=Please Enter your email address to authenticate with: "
IF NOT DEFINED _Email (
ECHO. Aborting! No Email Provided!
SET "_eLvl=1"
GOTO :EOF
)
SET /P "_PW=Please Enter your Password: "
IF NOT DEFINED _PW (
ECHO. Aborting! No Password Provided!
SET "_eLvl=2"
GOTO :EOF
)
NET USE I: /D /Y >NUL
NET USE I: /D /Y >NUL
NET USE >NUL
(
NET USE I: "%_SharepointPath%" /USER:%_Email% %_PW% /Persistent:NO
) || (
ECHO. Drive Mapping Failed!
SET "_eLvl=3"
)
(
ENDLOCAL
SET "_PW="
SET "_eLvl=%_eLvl%"
)
Pause
GOTO :EOF
Trying this on my machine, signing out, removing shares, reboots etc.
Thanks
John
ASKER
No Joy Ben :-( still not mapping...
ASKER
Didnt quite work but happy with the effort put in. Thanks
Not sure if you ever got this working. I work for the developer of a commercial client application that will do this. The drive can remain persistent and WebDAV file locking is supported. There's a 10 day free trial if you want to try it out. www.webdrive.com
Open in new window