vbscript 运行程序

6:17 PM 9/1/2011@is2120

1. 不出现cmd窗口,运行程序

Set objShell = CreateObject("Wscript.Shell")

strCommand = "win32pad d:\mydoc\log\note.log"
Set objExec = objShell.Exec(strCommand)

2. 删除默认共享
strComputer = "."
Set objWMIService = GetObject ( "winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2" )

Set colShares = objWMIService .ExecQuery _
( "Select * from Win32_Share" )

For Each objShare in colShares
If InStr ( Right (objShare . Name , 1 ), "$" ) Then
WScript .Echo "Deleting " & objShare . Name
objShare . Delete
End If
Next


3. runas
Set objSh = CreateObject ( "Shell.Application" )
strCommand = "notepad.exe"
objSh .ShellExecute strCommand , "" , "" , "runas" , 1

4. 关闭显示器
Set objSh = CreateObject ( "Shell.Application" )
strCommand = "nircmd.exe monitor off"
objSh .ShellExecute strCommand , "" , "" , "runas" , 1

Set objShell = CreateObject("Wscript.Shell")

strCommand = " nircmd.exe monitor off"
Set objExec = objShell.Exec(strCommand)

你可能感兴趣的:(VBScript)