ShellExecute(Handle,'open','cmd.exe',PChar('/c "C:\WINDOWS\system32\aa.bat"'),nil,SW_HIDE); //SW_SHOW/SW_HIDE
将下面的批处理文件不写成bat文件,在delphi内部写如何处理?
type C:\WINDOWS\system32\drivers\etc\hosts
type C:\WINDOWS\system32\drivers\etc\hosts | find "192.168.1.161" && goto yes
::echo 192.168.1.161 192.168.1.161 >> ""
echo 192.168.1.161 192.168.1.161 >> C:\WINDOWS\system32\drivers\etc\hosts
:yesreg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains\192.168.1.161" /v http /t REG_DWORD /d 0x00000002 /f
将下面的批处理文件不写成bat文件,在delphi内部写如何处理?
type C:\WINDOWS\system32\drivers\etc\hosts
type C:\WINDOWS\system32\drivers\etc\hosts | find "192.168.1.161" && goto yes
::echo 192.168.1.161 192.168.1.161 >> ""
echo 192.168.1.161 192.168.1.161 >> C:\WINDOWS\system32\drivers\etc\hosts
:yesreg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains\192.168.1.161" /v http /t REG_DWORD /d 0x00000002 /f
解决方案 »
- webbrowser递归遍历网页元素问题求教!
- 【虎年贺岁,平安幸福】
- 关于多线程读文件问题。
- 我想在Form_Close事件中用Initialization节却出现“Statement expected but 'INITIALIZATION' found”错误
- 连接ACCESS数据库时出现"未找到提供程序.该程序可能未正确安装" 应如何解决??找了很久也没找到答案??
- 实时建立dsp的可不可行??谁在项目中使用动态建立的dsp??
- 关于读取excel表
- 解释一下 如下的代码。
- 莱鸟急救关于SQL语句的问题!急急急,在线等待。
- 求解,这个程序有人说测试成功,有一些不成功?
- 散分,给D版聚点人气
- 为什么连成功后Timer1控件就不在循环了
s:string;
begin
str:=TStringlist.Create;
try
str.LoadFromFile('C:\WINDOWS\system32\drivers\etc\hosts');
if pos('192.168.1.161',str.Text)>0 then
begin
str.Append('');
str.Append('192.168.1.161 192.168.1.161');
str.SaveToFile('C:\WINDOWS\system32\drivers\etc\hosts');
s:='reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\'
+'Internet Settings\ZoneMap\Domains\192.168.1.161" /v http /t REG_DWORD /d 0x00000002 /f';
WinExec(PChar(s),SW_HIDE);
end;
finally
str.Free;
end;
end;
var str:TStrings;
s:string;
begin
str:=TStringlist.Create;
try
str.LoadFromFile('C:\WINDOWS\system32\drivers\etc\hosts');
if pos('192.168.1.161',str.Text)<1 then //文件中找不到 192.168.1.161
begin //在文件中加入一行 192.168.1.161 192.168.1.161:
str.Append('192.168.1.161 192.168.1.161');
str.SaveToFile('C:\WINDOWS\system32\drivers\etc\hosts');
end;
//在注册表增加一个 192.168.1.161 键:
s:='reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\'
+'Internet Settings\ZoneMap\Domains\192.168.1.161" /v http /t REG_DWORD /d 0x00000002 /f';
WinExec(PChar(s),SW_HIDE);
finally
str.Free;
end;
end;