Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

script to map network drive gives error when logging off

Status
Not open for further replies.

capkirk

Technical User
Jun 4, 2007
92
US
I have the following script to map a network drive on certain users PCs. when they log OFF, they get an error message that states "the locla device name is already in use. code is 80070055, source WSHNetwork.MapNetworkDrive.

what to I need to change in the vbs script to fix this?

here is the script:
Dim objNetwork
Set objNetwork = WScript.CreateObject("WScript.Network")
objNetwork.MapNetworkDrive "p:", "\\myserver\myfolder
 
does it run every time they log off? If it does, its trying to remap it every time, giving you that error. Either unmap the drive before mapping it or add an if statement to prevent it from being mapped a second time
 
How are you running the script? Through a GPO or some other way? Could you attach the entire script also?
 
Why not use a batchfile that includes the "net use" command? I have one of those that runs at logon and maps 5 network drives and also 8 network printers. Makes life super easy.
 
That is a GREAT FAQ! ;-)

It sounds to me like you have your script configured as a log off script rather than a log on script. I might be wrong so please let us know.

You will notice a section in my sample script where I first remove all mapped drives before mapping the new ones. This is handy because it allows you to ensure you have standardized mappings to drive letters.



I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
that helped a lot!

yeah, I had it configured as a log off script, we had an issue once where some users comlained it took several minutes for their PCs to come up all the way, and it was beleived to be due to a log on script I had, so they had me change it to a log off script.
 
If you posted the entire script it might shed some light on why it is slowing down your logins.
 
well, I was told "from above" to make the script GrimR's thread refers to as a log off script.

I do not know for a fact that was what was slowing down logins, but several users complained, and it was a few days after I had implemented an inventory login script. (gives all kinds of info about the PC, exports it to excel)

it was only a few users (out of 100) that complained, but none have complained since I moved it to a logoff script.

now this new login script to map drives was only for 5 users, and none of them have complained (yet)

oh, I see above I said the to markdmac that this one to map drives was logoff, it is actually login. sorry about that. it was a busy day, and I hadnt had nearly enough coffee.
 
So based on the previous reply, why not make the inventory script run once a month, as inventory wont change much
e.g.
Code:
'Now Create a registry value so if this is run it wont run again for a Month
'==========================================================================
varToday = (Date)

Verify = "HKLM\SOFTWARE\MyInstallsAndFixes\"

'Check if scan has run today and if so Exit
On Error Resume Next
LastRunDate = WshShell.RegRead(Verify & "WhatYouWantToCallIT")
On error goto 0
If DateDiff("d", LastRunDate, varToday) < 30 Then
   WScript.Quit
Else
  WshShell.RegWrite Verify & "WhatYouWantToCallIT",Date,"REG_SZ"
End If
 
thats pretty cool. I just might have to do that.
thanks.
 
Another option is of course to implement both login and logoff scripts.

Use login script as it is intended and configure the user environment. Use a logoff script for your inventory.

Even if you use the suggested method above to limit how frequently it runs, I would still break it apart this way. In doing so you ensure your users are not waiting for an inventory to complete while waiting to gain access to their PC.

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top