seaweed27
asked on
Logon scripts .vbs - remove pop up window
When this script executes, a window pops up which requires a user to click "ok". I would prefer it execute without promting the user to click "ok",or even notifying the user. Is this possible, if so how would i accomplish the task.
tia
seaweed27
tia
seaweed27
' Already.vbs Windows Logon Script
' VBScript to map a network drive.
' Author Guy Thomas http://computerperformance.co.uk/
' Version 1.7 - April 24th 2005
' ------------------------------------------------------'
Option Explicit
Dim strDriveLetter, strRemotePath
Dim objNetwork, objShell
Dim CheckDrive, AlreadyConnected, intDrive
' The section sets the variables.
strDriveLetter = "L:"
strRemotePath = "\\server\share"
' This sections creates two objects:
' objShell and objNetwork and counts the drives
Set objShell = CreateObject("WScript.Shell")
Set objNetwork = CreateObject("WScript.Network")
Set CheckDrive = objNetwork.EnumNetworkDrives()
' This section deals with a For ... Next loop
' See how it compares the enumerated drive letters
' with strDriveLetter
On Error Resume Next
AlreadyConnected = False
For intDrive = 0 To CheckDrive.Count - 1 Step 2
If CheckDrive.Item(intDrive) =strDriveLetter _
Then AlreadyConnected =True
Next
' This section uses the If = then, else logic
' This tests to see if the Drive is already mapped.
' If yes then disconnects
If AlreadyConnected = True then
objNetwork.RemoveNetworkDrive strDriveLetter
objNetwork.MapNetworkDrive strDriveLetter, strRemotePath
' The first message box
objShell.PopUp "Drive " & strDriveLetter & _
"Disconnected, then connected successfully."
Else
objNetwork.MapNetworkDrive strDriveLetter, strRemotePath
objShell.PopUp "Drive " & strDriveLetter & _
" connected successfully." End if
WScript.Quit
' Guy's Script ends here
ASKER
Can you tell me what i did wrong, thanks for helping
' Already.vbs Windows Logon Script
' VBScript to map a network drive.
' Author Guy Thomas http://computerperformance.co.uk/
' Version 1.7 - April 24th 2005
' ------------------------------------------------------'
Option Explicit
Dim strDriveLetter, strRemotePath
Dim objNetwork, objShell
Dim CheckDrive, AlreadyConnected, intDrive
' The section sets the variables.
strDriveLetter = "G:"
strRemotePath = "\\Srvr\Data"
' This sections creates two objects:
' objShell and objNetwork and counts the drives
Set objShell = CreateObject("WScript.Shell")
Set objNetwork = CreateObject("WScript.Network")
Set CheckDrive = objNetwork.EnumNetworkDrives()
' This section deals with a For ... Next loop
' See how it compares the enumerated drive letters
' with strDriveLetter
On Error Resume Next
AlreadyConnected = False
For intDrive = 0 To CheckDrive.Count - 1 Step 2
If CheckDrive.Item(intDrive) =strDriveLetter _
Then AlreadyConnected =True
Next
' This section uses the If = then, else logic
' This tests to see if the Drive is already mapped.
' If yes then disconnects
If AlreadyConnected = True then
objNetwork.RemoveNetworkDrive strDriveLetter
objNetwork.MapNetworkDrive strDriveLetter, strRemotePath
' The first message box
'objShell.PopUp "Drive " & strDriveLetter & _
'"Disconnected, then connected successfully."
Else
objNetwork.MapNetworkDrive strDriveLetter, strRemotePath
'objShell.PopUp "Drive " & strDriveLetter & _
'" connected successfully." End if
WScript.Quit
' Guy's Script ends here
logonscript-error2.bmp
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Line 43 - move the "End If" to a new line before the WScript.Quit one.
lol great minds think alike!
exx
Open in new window