Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Wscript objects
Message
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Title:
Miscellaneous
Thread ID:
00143154
Message ID:
00143250
Views:
26
>>I was playing around last night, and found a whole host of Automation servers derived from Wscript - the most interesting ones derived from wscript.network and wscript.shell, which seem to work well under NT 4.0 and Win98. Are the Wscript-derived objects available under Win95?
>>
>>Ed
>
>I too have been looking at WSH. John Petersen gave me an assist on using them as far as getting to the wscript.network and wscript.shell, but how do you reference a wscript object? I even tried the following code in VB6 and it bombed. I can't get a handle on a wscript object.
>

On my machine at home running Win98, the following two lines of code open up a WshNetwork object and a WshShell object respectively:

oWshNet = CREATEOBJ('Wscript.network')

oWshShell = CREATEOBJ('Wscript.shell')

>
dim argv, CRLF, dsObj, dsRoot, rc, usrObj, wshShell, xlFile, xlObj
>CRLF = Chr(13) & Chr(10)
>dsRoot = "WinNT://LAB"
>
>set wshShell = Wscript.CreateObject("Wscript.Shell")
>rc = wshShell.Popup("This sample script add users to a NT 4.0 SAM DB." & _
>                     CRLF & "Continue?", _
>                    60, _
>                    "WSH Sample", _
>                    vbYesNo + vbQuestion)
>If rc <> vbYes Then
>   Wscript.Quit(1)
>End If
>
>set argv = Wscript.Arguments
>If argv.Count = 0 Then
>   xlFile = InputBox("Enter the path and filename to the Excel " & _
>                     "spreadsheet containing the list of users to add:")
>Else
>   xlFile = argv.Item(0)
>End If
>
>If xlFile = "" Then
>   rc = wshShell.Popup("Script error. No input file specified.", _
>                       10, _
>                       "WSH Sample", _
>                       vbOKOnly + vbExclamation)
>   Wscript.Quit(1)
>End If
>
>set xlObj = Wscript.CreateObject("EXCEL.application")
>xlObj.Visible = True
>xlObj.workbooks.open(xlFile)
>xlObj.sheets("AddUsers").Activate
>xlObj.ActiveSheet.range("A2").Activate
>
>set dsObj = GetObject(dsRoot)
>
>Do While xlObj.activecell.Value <> ""
>   set usrObj = dsObj.Create("user", xlObj.activecell.Value)
>
>   usrObj.FullName      = xlObj.activecell.offset(0,1).Value + " " + _
>                          xlObj.activecell.offset(0,2).Value
>   usrObj.Description   = xlObj.activecell.offset(0,3).Value
>   usrObj.HomeDirectory = xlObj.activecell.offset(0,4).Value + _
>                          xlObj.activecell.Value
>   usrObj.LoginScript   = xlObj.activecell.offset(0,5).Value
>   usrObj.Profile       = xlObj.activecell.offset(0,6).Value + _
>                          xlObj.activecell.Value + ".usr"
>
>   usrObj.SetInfo
>
>   set usrObj = Nothing
>   xlObj.activecell.offset(1, 0).Activate
>Loop
>
>xlObj.application.quit
>rc = wshShell.Popup("Script completed successfully.", _
>                    10, _
>                    "WSH Sample", _
>                    vbOKOnly + vbInformation)
>Wscript.Quit(0)
>
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform