You have mismatched statements somewhere. You definitely need an End Sub at the 
end here. But that doesn't necessarily mean you have fixed all the issues. If 
it's complaining about line 150 then you have potentially opened something 
somewhere else that isn't closed yet.

Easiest way is to indent your code. Then you can see what doesn't line up.

Sub DriveMapper(Drive, Share)

   For i = 0 to oDrives.Count -1 Step 2

      If LCase(Drive) = LCase(oDrives.Item(i)) Then

         If not LCase(Share) = LCase(oDrives.Item(i+1)) Then

            WSHNetwork.RemoveNetworkDrive Drive, true, true

         Else

            Exit Sub

         End if

      End if

   Next

   ' (Line 150)
   ' Give the PC time to do the disconnect, wait 300 milliseconds
   wscript.sleep 300
   WSHNetwork.MapNetworkDrive Drive, Share

End Sub ' <-- You need this at the very least

I'd also refactor the code to avoid the use of global variables if at all 
possible. And you can use a two-dimensional array (or Hash Table) to simplify 
the code (you're checking every second array item at the moment for a drive, 
and then every other item for a share)

Cheers
Ken

From: Tim Wagerle [mailto:[EMAIL PROTECTED]
Sent: Saturday, 29 March 2008 8:51 AM
To: NT System Admin Issues
Subject: vbs script problem

I did not write this script, but it is throwing an error screen.  I know next 
to nothing about vbs.  If needed I can post the whole script but here is the 
section that, appears to, say it is in error.  The error message ask for 'end'  
and I have tried end, end sub, end function, to no avail.  Thanks

'Program that maps the drives - Make no changes from here down
Sub DriveMapper(Drive, Share)
For i = 0 to oDrives.Count -1 Step 2
if LCase(Drive) = LCase(oDrives.Item(i)) then
if not LCase(Share) = LCase(oDrives.Item(i+1)) then
WSHNetwork.RemoveNetworkDrive Drive, true, true
Else
Exit Sub
End if
End if
Next
'(Line 150)
'Give the PC time to do the disconnect, wait 300 milliseconds
wscript.sleep 300
WSHNetwork.MapNetworkDrive Drive, Share


Tim Wagerle, TSS
Josephine County Circuit Court
Oregon Judicial Department
[EMAIL PROTECTED]<mailto:[EMAIL PROTECTED]>


Tim Wagerle, TSS
Josephine County Circuit Court
Oregon Judicial Department
[EMAIL PROTECTED]





~ Upgrade to Next Generation Antispam/Antivirus with Ninja!    ~
~ <http://www.sunbelt-software.com/SunbeltMessagingNinja.cfm>  ~

Reply via email to