Sunday, November 21, 2010

WMI examples

'Set Obj = CreateObject("WScript.Shell")
' val = Obj.Run ("net user rupakala pa$$w0rd /add") -- will execute at command prompt, as background process
'val = Obj.Run ("cmd /K perl c:/Perl/eg/example.pl >c:/testfile.txt")     ' output will be written into testfile.txt
'msgbox val ' returns 0
'Obj.CreateShortcut "C:\Users\Administrator\Desktop\aaaaa.lnk"
' msgbox Obj.CurrentDirectory    '  -----displays current directory path of  script
'set WshSysEnv = Obj.Environment("SYSTEM")
'msgbox WshSysEnv.Item("OS")
'set exe = Obj.Exec ("notepad.exe")
' --- WMI  examples
'Set LoginProfiles = GetObject("winmgmts:").InstancesOf ("Win32_NetworkLoginProfile")
'   For each Profile in LoginProfiles
'     msgbox Profile.Name
'     'msgbox Profile.LogonName
'   next
Set net = CreateObject("WScript.Network")   
' net.MapNetworkDrive "P:", "file://pc/public%22,%22True%22,%22Administrator",""
'msgbox net.ComputerName
'msgbox net.UserName
Set oDrives = net.EnumNetworkDrives()
msgbox oDrives.Count
        For i = 0 to oDrives.Count - 1 Step 2
          msgbox "Drive " & oDrives.Item(i) & " = " & oDrives.Item(i+1)
         Next

No comments:

Post a Comment

 

©2010 Software Testing powered by Free Blogger Templates | Author : Anand Satish