Contents of Guy's Scripting Ezine No 1 - Do While... Loops
I will let you into a secret; this is the first edition of my newsletter. There
is always something exiting about the start of a new venture. This week I feature a logon script. The script has twin goals:
1) To give Windows 98 clients enough TIME to logon before executing the
script commands
2) To introduce you to the DO WHILE ... LOOP statement. Instructions:Copy the Script below, paste into notepad, save with .vbs extension e.g Time.vbs.
Doubleclick to test
'VBScript ' Purpose to show the Sleep Command
Option Explicit
Dim oNet, sUser, startTime
Set oNet = CreateObject("WScript.Network")
' Get the user name. On Windows 98 the user may not be logged on
sUser = oNet.UserName
startTime = Now
Do While sUser = ""
If DateDiff("s", startTime, Now) > 30 Then Wscript.Quit
Wscript.Sleep 500
sUser = oNet.UserName
LOOP
' Add a network share for the "K" home drive
' NOTE Change alan to the name of your Server
' Check home exists
' Check a user called Guyt exists or else use & sUser
' Example oNet.MapNetworkDrive "K:", "\\alan\home\" & sUser
oNet.MapNetworkDrive "K:", "\\alan\home\Guyt"
WScript.Echo "K Drive Created"
'end of script
Footnote - This
first edition of the Ezine was just a beginning, future
Ezines were longer with more details. In due course the Ezine grows to include
'Guy challenges' and 'out takes'.
Their topics and material are ideal for getting you started with VBScript. The
videos are easy to follow and you can control the pace. Try their free demo material and then see if you want to buy the full package.
See more about VB Script Training CD.
|