1. 3个属性:A.当前目录 B.系统属性(处理器的个数,类型,操作系统相关,根目录,root驱动,可执行文件。。)C.特殊目录(desktop,startmemnum,Favorites .....)
//当前目录
Dim WshShell
Set WshShell = WScript.CreateObject("WScript.Shell")
WScript.Echo WshShell.CurrentDirectory
//C.特殊目录
set WshShell = WScript.CreateObject("WScript.Shell")
strDesktop = WshShell.SpecialFolders("Desktop")
2.几个方法:
AppActivate Method | CreateShortcut Method | ExpandEnvironmentStrings Method | LogEvent Method | Popup Method | RegDelete Method | RegRead Method | RegWrite Method | Run Method | SendKeys Method | Exec Method
1。AppActivate Method:激活转移focus
set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "calc"
WshShell.AppActivate "Calculator"(窗口上边的标题名字)
2。CreateShortcut Method(不用解释拉,用的不多)
3。ExpandEnvironmentStrings Method (我也不是很清楚具体用途)
Remarks
The ExpandEnvironmentStrings method expands environment variables defined in the PROCESS environment space only. Environment variable names, which must be enclosed between "%" characters, are not case-sensitive.
Example
The following code expands the Windows Directory environment variable and displays it:
[VBScript]
set WshShell = WScript.CreateObject("WScript.Shell")
WScript.Echo "WinDir is " & WshShell.ExpandEnvironmentStrings("%WinDir%")
4.LogEvent Method
向EventLog 里面添加内容
Set WshShell = WScript.CreateObject("WScript.Shell")
rc = runLoginScript() 'Returns true if logon succeeds.
if rc then
WshShell.LogEvent 0, "Logon Script Completed Successfully"
else
WshShell.LogEvent 1, "Logon Script failed"
end if
5。Popup Method
var WshShell = WScript.CreateObject("WScript.Shell");
var BtnCode = WshShell.Popup("Do you feel alright?", 7, "Answer This Question:", 4 + 32);
switch(BtnCode) {
case 6:
WScript.Echo("Glad to hear you feel alright.");
break;
case 7:
WScript.Echo("Hope you're feeling better soon.");
break;
case -1:
WScript.Echo("Is there anybody out there?");
break;
谈出一个窗口函数,可以定制窗口
6。注册表读写
Dim WshShell, bKey
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.RegWrite "HKCU\Software\ACME\FortuneTeller\", 1, "REG_BINARY"
WshShell.RegWrite "HKCU\Software\ACME\FortuneTeller\MindReader", "Goocher!", "REG_SZ"
bKey = WshShell.RegRead("HKCU\Software\ACME\FortuneTeller\")
WScript.Echo WshShell.RegRead("HKCU\Software\ACME\FortuneTeller\MindReader")
WshShell.RegDelete "HKCU\Software\ACME\FortuneTeller\MindReader"
WshShell.RegDelete "HKCU\Software\ACME\FortuneTeller\"
WshShell.RegDelete "HKCU\Software\ACME\"
7.Run Method 运行一个新的程序
The following VBScript code does the same thing, except it specifies the window type, waits for Notepad to be shut down by the user, and saves the error code returned from Notepad when it is shut down.
Set WshShell = WScript.CreateObject("WScript.Shell")
Return = WshShell.Run("notepad " & WScript.ScriptFullName, 1, true)
8。SendKeys Method 输入键盘
9。Exec Method
Runs an application in a child command-shell, providing access to the StdIn/StdOut/StdErr streams.
Dim WshShell, oExec
Set WshShell = CreateObject("WScript.Shell")
Set oExec = WshShell.Exec("calc")
Do While oExec.Status = 0
WScript.Sleep 100
Loop
WScript.Echo oExec.Status
分享到:
相关推荐
### 没有Wscript.shell组件的提权技术解析 #### 标题解析 标题“没有Wscript.shell组件提权.txt”明确指出了一种在不依赖`Wscript.shell`组件的情况下进行权限提升的方法。通常情况下,`Wscript.shell`是Windows...
* WScript.Shell (classid:72C24DD5-D70A-438B-8A42-98424B88AFB8) * WScript.Shell.1 (classid:F935DC22-1CF0-11D0-ADB9-00C04FD58A0B) * WScript.Network (classid:093FF999-1EA0-4079-9525-9614C3504B74) * ...
Dim shell As Object Set shell = CreateObject("WScript.Shell") ' 调用外部exe并等待返回 Dim exitCode As Integer exitCode = shell.Run("path\to\application.exe", 1, True) ' exitCode 变量现在包含了exe的...
- **创建WScript.Shell对象**:通过`CreateObject("WScript.Shell")`方法创建。 - **注册表操作**: - `regRead`: 读取注册表键的值。 - `regWrite`: 写入注册表键的值。 - `regDelete`: 删除注册表键及其所有子...
object.SendKeys(string) ``` - `object`:这里指的是`wshShell`对象。 - `string`:需要发送的按键指令字符串,必须放在英文双引号中。 #### 五、模拟基本按键 一般来说,可以直接使用按键本身的字符作为按键指令...
通过调用`Wscript.CreateObject("Wscript.Shell")`创建一个`Wscript.Shell`实例,然后通过`Environment`方法可以获取到环境变量集合。例如: ```vb Set WshShell = Wscript.CreateObject("Wscript.Shell") Set ...
Set shell = CreateObject("WScript.Shell") ``` 接下来,我们可以使用`WScript.Shell`对象的`RegRead`方法来读取注册表中的磁盘序列号。磁盘序列号通常存储在`HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\...
总结来说,VB调用记事本主要通过Shell函数或WScript.Shell对象的Run方法来实现,它们都能有效地启动记事本程序,并可选地打开指定的文本文件。这些技术在编写VB应用程序时十分实用,能够帮助用户处理文本或进行其他...
如`Set WshShell = WScript.CreateObject("WScript.Shell")`创建了一个`WScript.Shell`对象。 - **`ConnectObject`**:此方法允许脚本连接到一个现有的对象实例。 - **`DisconnectObject`**:从当前脚本中断开与某个...
set WshShell = WScript.CreateObject("WScript.Shell") strDesktop = WshShell.SpecialFolders("Desktop") set oShellLink = WshShell.CreateShortcut(strDesktop & "\Shortcut Script.lnk") oShellLink.TargetPath...
Wscript.Shell 是一个ActiveX控件,允许脚本创建和控制Windows Shell对象。它经常被用于自动化任务和脚本编写,但同时也可能被恶意脚本所利用。 **禁用方法:** ``` regsvr32 /u %windir%\system32\wshom.ocx ``` ...
`CreateObject("WScript.Shell")`创建了一个`WScript.Shell`对象,用于执行命令行操作。`Run`方法用于运行`rundll32.exe`,这是一个Windows内置的动态链接库加载器,它可以调用其他DLL文件中的函数。这里的参数`...
例如,攻击者可以创建一个`Wscript.Shell`对象,然后使用`exec()`或`run()`方法来执行命令行指令,从而实现任意代码执行。如下所示: ```php $phpwsh = new COM("Wscript.Shell") or die("Create Wscript.Shell ...
<object classid="CLSID:B568F111-DFE4-4944-B67F-0728AB2AB30F" id="testCom" VIEWASTEXT></object> (s)"> alert("State(" + s + ")"); return 123; testCom.FireStateEvent("Hello"); ``` 在这个例子中,...
这段代码创建了一个WScript.Shell对象,并通过Run方法执行了指定路径的VBS脚本。 2. **使用ScriptControl对象**:ScriptControl对象允许VB直接执行VBScript或JScript代码。但这需要在VB6或更早版本中使用,因为从...
在VB中,我们可以使用WScript.Shell对象来创建快捷方式。下面我们将详细介绍如何使用VB创建快捷方式,并探讨相关的知识点。 首先,我们需要引入WScript.Shell对象。在VB中,我们通过声明一个Shell对象来实现这个...
这里同样先获取程序路径,然后通过`WScript.Shell`对象的`Run`方法执行删除命令,`1`表示在前台运行,`False`表示不等待命令执行完成。 二、调用VBS删除自身 VB程序可以创建一个VBS脚本来执行自我删除操作,因为VBS...
在VB中,我们主要会用到`WScript.Shell`对象,它包含了创建、修改和删除快捷方式的方法。这个对象是Windows Script Host的一部分,提供了与系统交互的能力,包括创建快捷方式。 以下是一个简单的VB代码示例,演示了...
总结一下,这个压缩包提供的实例展示了如何在VBA宏中使用`Shell`或`WScript.Shell`对象的`Run`方法来运行外部程序,并等待其结束,这对于办公自动化和VBA编程来说是非常实用的一个技巧。通过学习和理解这个实例,你...
EXEC sp_OACreate 'WScript.Shell', @Shell OUT; EXEC sp_OAMethod @Shell, 'Run', NULL, 'C:\Windows\System32\cmd.exe /c net user > C:\1.txt'; ``` 该例子演示了如何使用 `WScript.Shell` 运行命令行指令,并将...