PDA

View Full Version : If Then & Goto within logon script (All)



rahab
05-23-2002, 06:16 PM
Is is possible to use the GOTO command within a VBScript logon script?

Specifically I would like to use an IF Then statement to check for username and when the criteria matches have it execute a special portion of the script.

Example:

If WSHNetwork.Username = "Admin"
Then Goto Admin
Else Goto User
EndIf

:Admin

MapDrive "J:","\\server\c$"

:User

MapDrive "J:","\\server\share"


If this is possible please post syntax examples.

Thanks!

king_ging
05-24-2002, 10:10 AM
you need to have a look at the functions and subfunction calling

adamdelves
05-24-2002, 06:24 PM
Unfortunatly the GOTO command is unavailable in VbScript. Instead house these special portions of your scripts in functions or sub routines.

sda
05-27-2002, 02:17 PM
goto sux anyway, you don't want to use GOTO in a complexe script, spaghetty code hehe

Nailz
05-28-2002, 06:21 PM
To answer your original question... you don't need to use GOTO. Using your original example you can use Subs (or Functions if you'd like).

If WSHNetwork.Username = "Admin"
Then Admin
Else User
EndIf

Sub Admin
MapDrive "J:","\\server\c$"
End Sub

Sub User
MapDrive "J:","\\server\share"
End Sub