PDA

View Full Version : Log on script and offline files (WXP-Pro)



sym
04-15-2005, 02:31 AM
Hi,

We have about 6 shares that we want mapped at logon using a bat file. I can map them fine, but the next time the file is run it throws errors saying the drive letter is in use. I can fix that by using /delete within the NET USE command but heres where the problem comes;

Some of the drives have offline files on them including the documents and office templates we use. They can't be on the users computer but we want them if the servers go down/they work offline etc. The /delete switch will remove all the offline files so when I use NET USE again the drive maps but the offline files need setting up again.

Any ideas? I can use VBS if needed.

Using all Windows XP SP2 clients and 2003 servers on a domain.

Thanks

Brf
04-15-2005, 06:30 AM
Just let it throw the errors.... it should cause no harm that way.

sym
04-15-2005, 06:32 AM
But then if we want to change the location of the mapped drive we'll hve to delete the drive and remap it, then reset up the offline files. That would be fine if everyone loged in on the same day, but people won't (holidays etc).

Anyway, it's a messy way of doing it, isn't it?

Brf
04-15-2005, 10:39 AM
In that case you would have to remap them and lose your offline files anyway.....

If you have to move the files, use the /delete flag... otherwise dont.

sym
04-15-2005, 10:59 AM
So your reply to my question is what?

I don't think you quite understand my problem. I want to use a script to keep the drives mapped to the right paths and update them when they change.

Actually, now I think about it I couls judt make a script to check the drive letter. IT still seems like a bad way of doing itt, but seeing no one seems to know a better way I'll have to stick with it.

Thanks

Brf
04-15-2005, 11:17 AM
What I would do is use the /delete if you have to move the shares to a different location. Once everyone is settled in with their new offline files mapped, then take the /delete out and let the errors bounce.

Personally, we dont use offline files here... assuming everyone will always be online... So we use a /delete and then a map in the logon script. In fact we even use non-persistant mappings, so there is nothing to delete:

net use z: /delete
net use /persistent:NO
net use z: \\rdc01\common

sym
04-15-2005, 11:23 AM
But the problem then comes when laptop user A is on holiday for 2 weeks with offline files being worked on and laptop user B has the folder remapped every day for the 2 weeks meaning that offline files won't work for them for that time. OR thes user A comes back the directory will have changed and the offline files won't sync.

That is not an option anyway.

Brf
04-15-2005, 12:13 PM
Maybe you could use a script.
Use a WshNetwork object and use the Enumnetworkdrives method to check the current drive mapping. If it isnt the desired one, use removenetworkdrive and mapnetworkdrive to put it right.

Something like this:

Set WshNetwork = WScript.CreateObject("WScript.Network")
Set oDrives = WshNetwork.EnumNetworkDrives
sDLetter = "X:"
sDShare = "\\myserver\myshare"
found=0
For i = 0 to oDrives.Count - 1 Step 2
if oDrives.Item(i) = sDLetter then
if oDrives.Item(i+1) = sDShare then
found = 1
else
found = 2
end if
end if
Next
if found = 1 then
'wscript.echo "OK"
end if

if found=2 then
'wscript.echo "disconnecting"
WshNetwork.RemoveNetworkDrive sDLetter, true, true
end if
if found <> 1 then
'wscript.echo "connecting"
WshNetwork.MapNetworkDrive sDLetter, sDShare, true
end if

<P ID="edit"><FONT class="small">Edited by Brf on 04/15/05 06:55.</FONT></P>