braise脚本学习实践--删除微信和QQ本地缓存文件

// C:\Users\Public\Documents\Tencent\QQ
//C:\Users\warrior\Documents\WeChat Files
//获取当前登陆用户
function get_cu_login_u()
{
ret1 = process.shell("echo [tchtemp] > c:\temp.txt");
if(ret1 != 0)
{
return ;
}
ret1 = process.shell("echo cluser=%username% >>c:\temp.txt");
if(ret1 != 0)
{
return ;
}
cluser = ini.read_string("c:\temp.txt","tchtemp","cluser");
process.shell("del /q c:\temp.txt");
return cluser;
}

//是否存在路径
function is_exist_path(str_file_path)

{
b_exist = file.is_exist(str_file_path);
if(b_exist)
{
return true;
}
}

//删除目录操作
function delete_dir(str_file_path)
{
if(is_exist_path(str_file_path))
{
//如果目录存在删除后返回true
return file.delete_dir_recur(str_file_path);
}
}

//获取qq设置保存文件路径
function get_qq_file_save_path()
{
str_file_path = "C:\Users\Public\Documents\Tencent\QQ\UserDataInfo.ini";
i_UserDataSavePathType = ini.read_int(str_file_path, "UserDataSet", "UserDataSavePathType");
if(i_UserDataSavePathType != 1)
{
qq_file_save_path = ini.read_string(str_file_path, "UserDataSet" ,"UserDataSavePath");
return qq_file_save_path;
}
}

//获取微信设置保存文件路径
function get_wechat_file_save_path()
{
r = new ("reg");
b = r.open_dir("HKEY_CURRENT_USER\Software\Tencent\WeChat", false, false, "sys");
if(b)
{
str_file_path = r.read_str("FileSavePath");
if(str_file_path.result )
{
return str_file_path.value;
}
}
delete(r);
}

function main()
{
//qq默认文件保存路径
str_def_file_path_qq = "c:\Users\" + get_cu_login_u() + "\Documents\Tencent Files";
//微信默认保存路径
str_def_file_path_wechat = "c:\Users\" + get_cu_login_u() + "\Documents\WeChat Files";

if( is_exist_path(str_def_file_path_qq))
{
	io.println(delete_dir(str_def_file_path_qq));
}
if( is_exist_path(str_def_file_path_wechat))
{
	io.println(delete_dir(str_def_file_path_wechat));
}
if(is_exist_path(get_qq_file_save_path()))
{
	io.println(delete_dir(get_qq_file_save_path()));
}
if(is_exist_path(get_wechat_file_save_path()))
{
	io.println(delete_dir(get_wechat_file_save_path()));
}

}
main();

上一篇:PAT (Advanced Level) Practice 1144 The Missing Number (20 分) 凌宸1642


下一篇:Spark读取Hive分区表出现Input path does not exist的问题!!