Microsoft® Windows® 2000 Scripting Guide
« Previous | Next »
Some WMI classes (including Win32_Share and Win32_Process) include a Create method. If a class includes the Create method, that method can be used to create such things as a new shared folder or a new process.
Creating a new resource requires you to use the Get method to bind to the actual WMI class (rather than retrieve instances of the class). After you have an object representing the class, use the SpawnInstance_ method to create a new, "blank," instance of the class. Configure properties for the instance, and then call the Create method.
The script template in Listing 6.27 uses the Create method to create a new shared folder.
Listing 6.27 Template for Creating Resources
|
|
To use this template with other WMI classes:
objInParams.Properties_.Item(
"Description
") =
"New Share Description
"objInParams.Properties_.Item(
"Name
") =
"New Share Name
"objInParams.Properties_.Item(
"Path
") =
"C:\scripts\shared
"objInParams.Properties_.Item(
"Type
") = 0
Send us your feedback | « Previous | Next » |