Link to home
Start Free TrialLog in
Avatar of seaweed27
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
' 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

Open in new window

Avatar of exx1976
exx1976
Flag of United States of America image

HTH,
exx
' 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

Open in new window

Avatar of seaweed27
seaweed27

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

Open in new window

logonscript-error2.bmp
ASKER CERTIFIED SOLUTION
Avatar of exx1976
exx1976
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Line 43 - move the "End If" to a new line before the WScript.Quit  one.
lol great minds think alike!