Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

WSH vs VBScript (what are they?) 2

Status
Not open for further replies.

sysmgr1

IS-IT--Management
Feb 6, 2004
3
US
What is Windows Script Host? How does it relate to VBScript?

I want to create a good logon script. I have extensive experience with KIXtart for logon scripts, but not WSH or VBScript.

Can someone please give me a quick brief-over on WSH and VBScript? I read that WSH is the successor to batch files; but everywhere I look to learn on WSH takes me off into VBScript.

Also, can someone recommend a good book for this.

Thanks!
 
Here is a login script I like to implement at my customer sites. It is useful in that it will map drives and printers for all users and can also map additional drives based on group memberships.

You can easily tweak it, remove sections etc to meet your needs.

'==========================================================================
'
' NAME: LogonScript
'
' AUTHOR: Mark D. MacLachlan, The Spider's Parlor
' URL : ' DATE : 4/10/2003
'
' COMMENT: Enumerates current users' group memberships in given domain.
'
'==========================================================================


ON ERROR RESUME NEXT

Set WSHShell = CreateObject("WScript.Shell")
Set WSHNetwork = CreateObject("WScript.Network")
DomainString = "DomainName"
UserString = WSHNetwork.UserName

Set UserObj = GetObject("WinNT://" & DomainString & "/" & UserString)

'Synchronizes the time with Server our NTP Server
'WSHShell.Run "NET TIME \\Server /set /y"


WSHNetwork.RemoveNetworkDrive "F:"

wscript.sleep 300

'Maps drives needed by all
WSHNetwork.MapNetworkDrive "U:", "\\server\users",True
WSHNetwork.MapNetworkDrive "X:", "\\server\executables",True

'Now check for group memberships and map appropriate drives
For Each GroupObj In UserObj.Groups

Select Case GroupObj.Name
'Check for group memberships and take needed action
Case "Admin"
WSHNetwork.MapNetworkDrive "w:", "\\Server\Admin Stuff",True
Case "WorkerB"
WSHNetwork.MapNetworkDrive "w:", "\\Server\Shared Documents",True

End Select

Next


'Install Printers

WSHNetwork.AddWindowsPrinterConnection "\\Server\HP5si"



set UserObj = Nothing
set GroupObj = Nothing
set WSHNetwork = Nothing
set DomainString = Nothing
set WSHSHell = Nothing

wscript.quit


I hope you find this post helpful. Please let me know if it was.

Regards,

Mark
 
Hello sysmgr1,

[1] Wsh (Windows Script Host) as the name suggests acts as a host/container to interprete/compile/execute scripts.
[2] At the heart of it is an ocx, wshom.ocx. Wscript.exe and/or cscript.exe act as a stub, a front-end, taking in script from the "real-world."
[3] Wsh acts upon, but not limited to, vbscript language. The obvious alternative ms offered is jscript language, a dialect of javascript. But if you issue at commandprompt,
Code:
    cscript /?
you'll see you are offered an option whereby you can specify your user script engine:
Code:
   Wscript|Cscript //E:engine
Hence, it is not at all unlikely that a perl script is being offered to the host.
[4] Besides, wsh exposes a small number of native objects which help extending some functionality.
[5] The vbscript is being processed under wsh by vbscript.dll. It is the script engine so to speak.
[6] The host has a bearing on the callback or event handling on the object created by the createobject function.
[7] Besides, there can be very subtled "bugs" and/or differences between vbscript engines operating under different hosts, wsh, iis, rds. But here, I cannot assert with full confidence.

Hope the above help clearing a bit of the cloud at the entrance level.

regards - tsuji
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top