Mapped networkdrive on logout

2

1

I'm using a script to keep a mapped networkconnection alive, but ofcourse the mapped connection is gone when I logout. The point is now, that I'm running this on Windows Server 2008 R2, where I use remote desktop to login on the administrator account. However, it should remain logged in and not remove the mapped connection as this script takes care of not logging out on MS office 365 sharepoint.

Is there a way to keep the mapped networklocation (L:) available after logout? So the script can run to remain the connection?

# Create an IE Object and navigate to my SharePoint Site

$ie = New-Object -ComObject InternetExplorer.Application
$ie.navigate('https://xxx.sharepoint.com/')

# Don't need the object anymore, so let's close it to free up some memory
$ie.Quit()

# Just in case there was a problem with the web client service
# I am going to stop and start it, you could potentially remove this
# part if you want. I like it just because it takes out a step of 
# troubleshooting if I'm having problems.

Stop-Service WebClient
Start-Service WebClient

# We are going to set the $Drive variable here, this is just
# going to tell the command what drive letter to map you can 
# change this to whatever you want (if you change it to a 
# drive that is already mapped it will overwrite it, so be careful.

$Drive = "L:"

# You can change the drive destiniation to whatever you want,
# it has to be a document library or folder of course.
$DrvDest = "https://xxx.sharepoint.com/files/"

# Here is where we create the object to map the network drive and
# then map the network drive
$net = New-Object -ComObject WScript.Network;
$net.mapnetworkdrive($Drive,$DrvDest)

# That is the end of the script, now schedule this with task
# scheduler and every so often and you should be set.

Rob

Posted 2012-10-16T06:47:30.477

Reputation: 511

If I understand you correctly, your actual problem is getting logged out of MS Office 365 when you log out of your remote desktop session and this is how you want to avoid that? – Der Hochstapler – 2012-10-16T10:17:42.557

I would like to keep the L: drive available on logout, or some other way around so I can run any .NET application that can use the L: to upload files to with that location. – Rob – 2012-10-16T12:25:40.633

Why? What applications? NT Services? Mapped drives are session specific. – snowdude – 2012-10-20T09:35:44.360

Answers

1

Instead of trying to keep a network drive open why not simply use the UNC path to the resource. e.g.

\\SERVER\Folder

instead of

L:

snowdude

Posted 2012-10-16T06:47:30.477

Reputation: 2 560

This is not an answer, \Server\folder is no drive I can map to. Can you explain me how to map to that folder? – Rob – 2012-10-16T09:18:03.193

Mapped drives only last for the 'session' in which the login exists. Are you trying to do something in an NT service? – snowdude – 2012-10-16T09:21:37.377

0

first you should learn how to:

Open SharePoint document library in windows explorer

then you can create a batch file, with net use command you will config which user to authenticate and can set the user and password for your desired shared folder

NET USE
[devicename | *] [\\computername\sharename[\volume] [password | *]]
        [/USER:[domainname\]username]
        [/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}]
if you need , you can map administrator shared folders that always hide for other users

saber tabatabaee yazdi

Posted 2012-10-16T06:47:30.477

Reputation: 1 323

1Can you tell me how I can use this to connect to a sharepoint with username and password? – Rob – 2012-10-30T15:41:57.213

1if you want to map a network drive, to PCs in your domain, they may report slow speed to open their "my computer"s because your server didn't respond immediately . – saber tabatabaee yazdi – 2012-10-31T04:19:02.090

when you are in any SharePoint Document Library with internet explorer, you will see option to "open this DL in windows explorer" and then if you replace "http://" by "\" and "/" by "" you can have windows address like shared folders in file servers. that named FQDN. by this address you can map a network drive – saber tabatabaee yazdi – 2012-10-31T04:22:29.540

for managed map network drive you can create a batch file script with those commands that above and place in GPO in Active Directory to run in all start up joined computers in your domain. (please if is this helpful +1, comments and answers) – saber tabatabaee yazdi – 2012-10-31T04:25:15.663