delphi下运行vbscript脚本
作者:互联网
简单一个vb脚本,功能为打开被限制的注册表。
Set wso = CreateObject("WScript.Shell")
wso.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System\DisableRegistryTools",0,"REG_DWORD"
wso.RegWrite "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System\DisableRegistryTools",0,"REG_DWORD"
delphi下运行,
1、import component,将activex的microsoft script control 1.0引入。
2、
uses MSScriptControl_TLB,
procedure tform2.runvbspt(code:tstrings);
var
VBSpt : TScriptControl;
SL : TStringList;
i : Integer;
begin
VBSpt := TScriptControl.Create(nil);
VBSpt.Language := 'VBScript';
SL := TStringList.Create;
try
// sl.LoadFromFile() 导入脚本文件
sl.AddStrings(code);
for i := 0 to SL.Count - 1 do begin
VBSpt.ExecuteStatement(SL[i]);
end;
finally
FreeAndNil(SL);
FreeAndNil(VBSpt);
end;
end;
procedure TForm2.BitBtn1Click(Sender: TObject);
begin
runvbspt(memo1.lines);
end;
标签:脚本,begin,code,end,vbscript,delphi,wso,SL,VBSpt 来源: https://www.cnblogs.com/blogpro/p/11452588.html