//原作者:张三疯
//功能改进:海娃(51windows)
//http://www.51windows.Net
//设置文本保存的默认目录,注意:程序不能创建二级目录
var fdir="D:\\\\MyCode";
var fsdir=fdir.replace(/\\\\/g,"\\");
var fdrive = fdir.substring(0,1);
var fsubdir = fdir.substring(4,fdir.length);
//以下内容不需更改
var fso, d, fl, fn, fo,foo,fs,fss,windir, WSHShell,fw,fww;
fso = new ActiveXObject("Scripting.FileSystemObject");
d = fso.GetDrive(fdrive);
WSHShell = WScript.CreateObject("WScript.Shell");
var errorChar=/(\/|:|\*|\?|"|\<|\>|\|)/;
//如果没有指定的驱动器,或者驱动器类型不是硬盘,或者目录名包含非法字符.则弹出错误信息
if (!fso.DriveExists(fdrive) || d.DriveType!=2 || errorChar.test(fsubdir))
{WSHShell.Popup("文本保存目录错误,请重新设置文本保存目录.");}
else
{
if (!fso.FolderExists(fsdir))
{fso.CreateFolder(fsdir);}
windir=fso.GetSpecialFolder(0);
fn=windir+"\\savetext.htm";
fl = fso.CreateTextFile(fn,true);
fl.WriteLine('');
fl.Close();
fo= windir+"\\openfolder.htm";
foo = fso.CreateTextFile(fo,true);
foo.WriteLine('');
foo.Close();
fw= windir+"\\51windows.htm";
fww = fso.CreateTextFile(fw,true);
fww.WriteLine('');
fww.Close();
var fb,fbb;
fb= windir+"\\blueidea.htm";
fbb = fso.CreateTextFile(fb,true);
fbb.WriteLine('');
fbb.Close();
var fc,fbc;
fc= windir+"\\csdn.htm";
fcc = fso.CreateTextFile(fc,true);
fcc.WriteLine('');
fcc.Close();
fs=windir+"\\google.htm";
fss = fso.CreateTextFile(fs,true);
fss.WriteLine('');
fss.Close();
fu=windir+"\\link.htm";
fuu = fso.CreateTextFile(fu,true);
fuu.WriteLine('');
fuu.Close();
WSHShell.RegWrite("HKCU\\Software\\Microsoft\\Internet Explorer\\MenuExt\\打开代码文件夹(&Z)\\",fo);
WSHShell.RegWrite("HKCU\\Software\\Microsoft\\Internet Explorer\\MenuExt\\51windows.Net(&Q)\\",fw);
WSHShell.RegWrite("HKCU\\Software\\Microsoft\\Internet Explorer\\MenuExt\\CSDN(&C)\\",fc);
WSHShell.RegWrite("HKCU\\Software\\Microsoft\\Internet Explorer\\MenuExt\\蓝色理想(&B)\\",fb);
WSHShell.RegWrite("HKCU\\Software\\Microsoft\\Internet Explorer\\MenuExt\\保存所选文本(&S)\\",fn);
WSHShell.RegWrite("HKCU\\Software\\Microsoft\\Internet Explorer\\MenuExt\\打开网址(&U)\\",fu);
WSHShell.RegWrite("HKCU\\Software\\Microsoft\\Internet Explorer\\MenuExt\\Google搜索\\",fs);
WSHShell.Popup("SaveText 安装成功!!!\n默认的文本保存目录为 " + fsdir);
}