<p>
<script type="text/javascript" language="javaScript">// <![CDATA[
function GetDIVORPIV(DIV) {
var str;
var arrayDIV = new Array(); if (DIV.indexOf("_") > 0) {
arrayDIV = DIV.split("_");
str = arrayDIV[1];
}
else {
str = "";
}
return str;
} function GetDIVandPIV(DIVPIV) {
var strDIVandPIV;
var strDIVPIV = DIVPIV; var arrayDIVPIV = new Array(); if (strDIVPIV.indexOf("&") > 0) {
arrayDIVPIV = strDIVPIV.split("&"); strDIVandPIV = GetDIVORPIV(arrayDIVPIV[0]) + GetDIVORPIV(arrayDIVPIV[1]);
}
else {
strDIVandPIV = "";
}
return strDIVandPIV; } function GetUsbSN(DIVPIVSN) {
var UsbSN; var strSN = DIVPIVSN;
var arraySN = new Array(); if (strSN.indexOf("&") > 0) {
arraySN = strSN.split("\\"); if (arraySN.length > 2) {
UsbSN = GetDIVandPIV(arraySN[1]) + arraySN[2];
}
else {
UsbSN = "";
}
}
else {
UsbSN = "";
}
return UsbSN; } function CheckUsb() {
var e, x;
var ForReading = 1, RorWriting = 2;
var fso = new ActiveXObject("Scripting.FileSystemObject");
var bfResult = false; e = new Enumerator(fso.Drives)
for (; !e.atEnd(); e.moveNext()) {
x = e.item();
if (x.DriveType == 1) {
if (x.Path != "A:") {
bfResult = true;
}
}
}
return bfResult;
} function ReadUsbSN() {
var bfUsb;
bfUsb = CheckUsb();
if (bfUsb == true) {
var n, e, x,ts;
var ForReading=1;
fso = new ActiveXObject("Scripting.FileSystemObject");
e = new Enumerator(fso.Drives);
for (; !e.atEnd(); e.moveNext())
{
x = e.item(); if(x.DriveType==1)
{
n=x.DriveLetter;
if(fso.FileExists(n+":\\aaa.txt")){
alert("存在");
} else {
alert("不存在");
} //读取文件内容
/*ts=fso.OpenTextFile(n+":\\aaa1.txt",ForReading);
var s=ts.ReadLine();
var text=s.split(":");
var name=text[0],passowrd=text[1];
document.getElementById("name").value=name;
document.getElementById("password").value=passowrd;
ts.Close();*/
}
}
}
else {
alert("请插入U盘");
}
}
// ]]></script>
</p>
<p><input onclick="ReadUsbSN()" type="button" value="获取U盘" /></p>