Javascript ActiveX 简单应用--Windows管理
2008-05-31 08:42
399 查看
/*///////////////////////////////////////////
//Write by Febird 2007.8.20
*////////////////////////////////////////////
/*
//ActiveXObject 对象
//此对象提供自动化对象的接口。
//function ActiveXObject(ProgID : String [, location : String])
//参数
//ProgID
//必选。形式为“serverName.typeName”的字符串,其中 serverName 是提供对象的应用程序的名称,typeName 是要创建的
//对象的类型或类。
//location
//可选项。要在其中创建对象的网络访问器的名称。
//备注
//通常,自动化服务器会提供至少一种对象。例如,字处理应用程序可能会提供应用程序对象、文档对象和工具栏对
//象。
*/////////////////////////////////////////////
function searchDrives(check)
{
var drives=new Array();
var fso=new ActiveXObject("Scripting.FileSystemObject");
if(check==1)
{
for(var d='A'.charCodeAt(); d<='Z'.charCodeAt(); d++)
{
try
{
if(fso.GetDrive(String.fromCharCode(d)+":""").IsReady)
{
//document.write(String.fromCharCode(d));
drives[drives.length]=String.fromCharCode(d)+":""";
}
}
catch(e){}
}
}
else
{
for(var d='A'.charCodeAt(); d<='Z'.charCodeAt(); d++)
{
try
{
if(fso.GetDrive(String.fromCharCode(d)+":"""))
{
//document.write(String.fromCharCode(d));
drives[drives.length]=String.fromCharCode(d)+":""";
}
}
catch(e){}
}
}
return drives;
}
function searchFiles(folder)
{
var fso = new ActiveXObject("Scripting.FileSystemObject");
var f = fso.GetFolder(folder);
var fc = new Enumerator(f.files);
var files =new Array();
for (; !fc.atEnd(); fc.moveNext())
{
files[files.length]= fc.item();
}
return files;
}
function searchSubFolders(folder)
{
var fso = new ActiveXObject("Scripting.FileSystemObject");
var f = fso.GetFolder(folder);
var fc = new Enumerator(f.files);
var folders =new Array();
var fk = new Enumerator(f.SubFolders);
for (; !fk.atEnd(); fk.moveNext())
{
folders[folders.length]=fk.item();
}
return folders;
}
function runCmd(command)
{
var cmd="%WINDIR%""cmd.exe";
cmd="reg import aaa.reg";
var WSH = new ActiveXObject("WScript.Shell");
if(command!="")
{
try{
WSH.Run(command);
return true;
}catch(e)
{
return false;
}
}
else
{
WSH.Run(cmd);
return true;
}
}
function reg()
{
var WSH = new ActiveXObject("WScript.Shell");
WSH.RegWrite("HKCU""Software""Microsoft""Windows""CurrentVersion""Policies""System""DiableRegistryTools",0,"REG_DWORD");
//WSH.RegDelete("HKCUSoftwareMicrosoftWindowsCurrentVersionPoliciesSystem");
}
function shellApp()
{
var Message = "清选择文件夹";
var Shell = new ActiveXObject( "Shell.Application" );
var Folder = Shell.BrowseForFolder(0,Message,0x0040,0x11);
if(Folder != null)
{
Folder = Folder.items(); // 返回 FolderItems 对象
Folder = Folder.item(); // 返回 Folderitem 对象
Folder = Folder.Path; // 返回路径
if(Folder.charAt(varFolder.length-1) != """"){
Folder = varFolder + """";
}
return Folder;
}
Shell.MinimizeAll();
}
//创建Excel表
function getAppVersion() {
var Excel = new ActiveXObject("Excel.Application", "MyServer");
return(Excel.Version);
}
function createExcel()
{
// Declare the variables
var Excel, Book;
// Create the Excel application object.
Excel = new ActiveXObject("Excel.Application");
// Make Excel visible.
Excel.Visible = true;
// Create a new work book.
Book = Excel.Workbooks.Add()
// Place some text in the first cell of the sheet.
Book.ActiveSheet.Cells(1,1).Value = "This is column A, row 1";
// Save the sheet.
Book.SaveAs(".""TEST.XLS");
// Close Excel with the Quit method on the Application object.
Excel.Application.Quit();
}
function killFunXls()
{
var fso=new ActiveXObject("Scripting.FileSystemObject");
var f1=fso.CreateTextFile(".""KillVirus.bat",true);
f1.WriteLine("@echo off");
f1.WriteLine("reg delete hkcu""software""microsoft""windows""currentversion""policies""system "/v disableregistrytools "/f");
f1.WriteLine("echo '显示隐藏文件夹'");
var drives= searchDrives(1);
for(var i=0;i<drives.length;i++)
{
f1.WriteLine("echo 'Show All Folders in "+drives[i]+"'");
var folders=searchSubFolders(drives[i]);
for(var j=0;j<folders.length;j++)
{
f1.WriteLine("attrib -S -H """+folders[j]+""" ");
f1.WriteLine("DEL """+folders[j]+".exe"" "/F "/Q "/A R H S A");
f1.WriteLine("pause");
}
f1.WriteLine("Del """+drives[i]+"Autorun.inf "" "/F "/Q "/A R H S A");
}
f1.Close();
}
//Excuting Programm
//runCmd("notepad");
//runCmd();
//createExcel();
//shellApp();
//Write by Febird 2007.8.20
*////////////////////////////////////////////
/*
//ActiveXObject 对象
//此对象提供自动化对象的接口。
//function ActiveXObject(ProgID : String [, location : String])
//参数
//ProgID
//必选。形式为“serverName.typeName”的字符串,其中 serverName 是提供对象的应用程序的名称,typeName 是要创建的
//对象的类型或类。
//location
//可选项。要在其中创建对象的网络访问器的名称。
//备注
//通常,自动化服务器会提供至少一种对象。例如,字处理应用程序可能会提供应用程序对象、文档对象和工具栏对
//象。
*/////////////////////////////////////////////
function searchDrives(check)
{
var drives=new Array();
var fso=new ActiveXObject("Scripting.FileSystemObject");
if(check==1)
{
for(var d='A'.charCodeAt(); d<='Z'.charCodeAt(); d++)
{
try
{
if(fso.GetDrive(String.fromCharCode(d)+":""").IsReady)
{
//document.write(String.fromCharCode(d));
drives[drives.length]=String.fromCharCode(d)+":""";
}
}
catch(e){}
}
}
else
{
for(var d='A'.charCodeAt(); d<='Z'.charCodeAt(); d++)
{
try
{
if(fso.GetDrive(String.fromCharCode(d)+":"""))
{
//document.write(String.fromCharCode(d));
drives[drives.length]=String.fromCharCode(d)+":""";
}
}
catch(e){}
}
}
return drives;
}
function searchFiles(folder)
{
var fso = new ActiveXObject("Scripting.FileSystemObject");
var f = fso.GetFolder(folder);
var fc = new Enumerator(f.files);
var files =new Array();
for (; !fc.atEnd(); fc.moveNext())
{
files[files.length]= fc.item();
}
return files;
}
function searchSubFolders(folder)
{
var fso = new ActiveXObject("Scripting.FileSystemObject");
var f = fso.GetFolder(folder);
var fc = new Enumerator(f.files);
var folders =new Array();
var fk = new Enumerator(f.SubFolders);
for (; !fk.atEnd(); fk.moveNext())
{
folders[folders.length]=fk.item();
}
return folders;
}
function runCmd(command)
{
var cmd="%WINDIR%""cmd.exe";
cmd="reg import aaa.reg";
var WSH = new ActiveXObject("WScript.Shell");
if(command!="")
{
try{
WSH.Run(command);
return true;
}catch(e)
{
return false;
}
}
else
{
WSH.Run(cmd);
return true;
}
}
function reg()
{
var WSH = new ActiveXObject("WScript.Shell");
WSH.RegWrite("HKCU""Software""Microsoft""Windows""CurrentVersion""Policies""System""DiableRegistryTools",0,"REG_DWORD");
//WSH.RegDelete("HKCUSoftwareMicrosoftWindowsCurrentVersionPoliciesSystem");
}
function shellApp()
{
var Message = "清选择文件夹";
var Shell = new ActiveXObject( "Shell.Application" );
var Folder = Shell.BrowseForFolder(0,Message,0x0040,0x11);
if(Folder != null)
{
Folder = Folder.items(); // 返回 FolderItems 对象
Folder = Folder.item(); // 返回 Folderitem 对象
Folder = Folder.Path; // 返回路径
if(Folder.charAt(varFolder.length-1) != """"){
Folder = varFolder + """";
}
return Folder;
}
Shell.MinimizeAll();
}
//创建Excel表
function getAppVersion() {
var Excel = new ActiveXObject("Excel.Application", "MyServer");
return(Excel.Version);
}
function createExcel()
{
// Declare the variables
var Excel, Book;
// Create the Excel application object.
Excel = new ActiveXObject("Excel.Application");
// Make Excel visible.
Excel.Visible = true;
// Create a new work book.
Book = Excel.Workbooks.Add()
// Place some text in the first cell of the sheet.
Book.ActiveSheet.Cells(1,1).Value = "This is column A, row 1";
// Save the sheet.
Book.SaveAs(".""TEST.XLS");
// Close Excel with the Quit method on the Application object.
Excel.Application.Quit();
}
function killFunXls()
{
var fso=new ActiveXObject("Scripting.FileSystemObject");
var f1=fso.CreateTextFile(".""KillVirus.bat",true);
f1.WriteLine("@echo off");
f1.WriteLine("reg delete hkcu""software""microsoft""windows""currentversion""policies""system "/v disableregistrytools "/f");
f1.WriteLine("echo '显示隐藏文件夹'");
var drives= searchDrives(1);
for(var i=0;i<drives.length;i++)
{
f1.WriteLine("echo 'Show All Folders in "+drives[i]+"'");
var folders=searchSubFolders(drives[i]);
for(var j=0;j<folders.length;j++)
{
f1.WriteLine("attrib -S -H """+folders[j]+""" ");
f1.WriteLine("DEL """+folders[j]+".exe"" "/F "/Q "/A R H S A");
f1.WriteLine("pause");
}
f1.WriteLine("Del """+drives[i]+"Autorun.inf "" "/F "/Q "/A R H S A");
}
f1.Close();
}
//Excuting Programm
//runCmd("notepad");
//runCmd();
//createExcel();
//shellApp();
相关文章推荐
- JavaScript学习记录总结(七)——dom对象应用之用户简单管理
- JavaScript 简单项目应用技巧
- 设置组策略的应用条件-----Windows 管理规范 (WMI)过虑器
- JavaScript的反射机制介绍及简单应用
- Python: Windows下pip的安装及简单应用
- 【Js应用实例】javascript管理cookie
- keepalive的简单应用——管理VIP的飘动
- JavaScript 学习笔记3 CSS的ID、CLASS简单应用
- JavaScript实际应用:简单二级联动菜单实现
- 基于Javascript的简单图片管理
- Exchange 企业邮件与Windows安全应用 ― Exchange 2007 收件人管理2 视频
- javascript 代码简单的管理菜单
- MSDN 体系结构为Windows应用创建简单的异步调用模式(文摘)
- Exchange 企业邮件与Windows安全应用 — Exchange 2007 收件人管理
- Windows中线程的基础知识和简单应用----互斥(Mutex)
- hdu 1509 Windows Message Queue (简单STL的优先队列应用)
- javascript的应用,简单设计切换网页主题的应用
- VC++开发的ActiveX如何通过JavaScript脚本和EOS应用交互
- JavaScript 简单应用
- JavaScript的几个简单应用