// Obtain the printer on the network
Function getnetprinter ()
{
VaR OBJ = new activexobject ("wscript. Network ");
VaR netprinter = obj. enumprinterconnections ();
For (I = 0; I <netprinter. Count (); I + = 2)
{
Document. writeln (netprinter. Item (I) + "=" + netprinter. Item (I + 1 ));
}
}
// Obtain the disk information. input parameters include getdiskinfo ('C ')
Function getdiskinfo (para)
{
VaR FS = new activexobject ("scripting. FileSystemObject ");
D = FS. getdrive (para );
S = "volume label:" + D. volumnname;
S + = "------" + "available space:" + D. freespace/1024/1024 + "M ";
S + = "------" + "disk serial number:" + D. serialnumber;
Alert (s)
}
// Obtain the system directory
Function getprocessnum ()
{
VaR pnsys = new activexobject ("wscript. Shell ");
Pn = pnsys. Environment ("process ");
Alert (Pn ("WINDIR "));
}
// Start the Calculator
Function runcalc ()
{
VaR calc = new activexobject ("wscript. Shell ");
Calc. Run ("calc ");
}
// Read the value in the Registry
Function readreg ()
{
VaR myreadreg = new activexobject ("wscript. Shell ");
Try {
Alert (myreadreg. regread ("HKEY_LOCAL_MACHINE // software // Microsoft // windows // CurrentVersion // run // nerocheck "));
}
Catch (E)
{
Alert ("the read value does not exist! ");
}
}
// Write the Registry
Function writereg ()
{
VaR mywritereg = new activexobject ("wscript. Shell ");
Try {
Mywritereg. regwrite ("HKEY_LOCAL_MACHINE // software // Microsoft // windows // CurrentVersion // run // mytest", "C: // mytest.exe ");
Alert ("written successfully! ");
}
Catch (E)
{
Alert ("the write path is incorrect! ");
}
}
// Delete the Registry
Function delreg ()
{
VaR mydelreg = new activexobject ("wscript. Shell ");
If (confirm ("are you sure you want to delete it? "))
{
Try {
Mydelreg. regdelete ("HKEY_LOCAL_MACHINE // software // Microsoft // windows // CurrentVersion // run // mytest ");
Alert ("deleted successfully! ");
}
Catch (E)
{
Alert ("the deletion path is incorrect ");
}
}
}
// Obtain the Computer Name Domain Name Username
Function netinfo ()
{
VaR mynetinfo = new activexobject ("wscript. Network ");
Alert ("computer name:" + mynetinfo. computername + "Domain Name:" + mynetinfo. userdomain + "username:" + mynetinfo. username );
}
// Return the path of the special directory in the system (fonts, allusersdesktop, desktop, mydocuments, recent .....)
Function getspecialfolder ()
{
VaR mygetfolder = new activexobject ("wscript. Shell ");
If (mygetfolder. specialfolders ("fonts ")! = NULL)
{
Alert (mygetfolder. specialfolders ("fonts "));
}
}
// Call method for obtaining file information, such as getfileinfo ('e: // myplace // test // myjs.htm ')
Function getfileinfo (para)
{
VaR myfile = new activexobject ("scripting. FileSystemObject ");
VaR Fi = myfile. GetFile (para );
Alert ("file type:" + fi. type + "file size:" + fi. size/1024/1024 + "M" + "last access time:" + fi. datelastaccessed );
}
// Obtain client information
Function clientinfo ()
{
Strclientinfo = "availheight =" + window. Screen. availheight + "/N" +
"Availwidth =" + window. Screen. availwidth + "/N" +
"Bufferdepth =" + window. Screen. bufferdepth + "/N" +
"Colordepth =" + window. Screen. colordepth + "/N" +
"Colorenable =" + window. Navigator. cookieenabled + "/N" +
"Cpuclass =" + window. Navigator. cpuclass + "/N" +
"Height =" + window. Screen. height + "/N" +
"Javaenable =" + window. Navigator. javaenabled () + "/N" +
"Platform =" + window. Navigator. Platform + "/N" +
"Systemlanguage =" + window. Navigator. systemlanguage + "/N" +
"Userlanguage =" + window. Navigator. userlanguage + "/N" +
"Width =" + window. Screen. width;
Alert (strclientinfo );
}
// Use the dilog Helper Object
Function changecolor () // call system palette for using the dilog Helper Object
{
VaR scolor = dlghelper. choosecolordlg ();
Scolor = scolor. tostring (16 );
If (scolor. length <6 ){
VaR stempstring = "000000". substring (-scolor. Length );
Scolor = stempstring. Concat (scolor );
}
Alert (scolor );
Mybody. style. backgroundcolor = scolor;
}
Function getfonts () // use the dilog helper object to obtain the fonts supported by the system
{
VaR strfonts = "";
For (VAR I = 1; I <dlghelper. fonts. Count; I ++)
{
Strfonts = strfonts + dlghelper. fonts (I) + "| ";
}
Alert (strfonts );
}
Function getblockformat () // use the dilog helper object to obtain the block format information in the system (for example, Title 1, Title 2 ....)
{
VaR strblockformat = "";
For (VAR I = 1; I <dlghelper. blockformats. Count; I ++)
{
Strblockformat = strblockformat + dlghelper. blockformats (I) + "| ";
}
Alert (strblockformat );
}
Function createtxtlink () // create a link to the selected text
{
VaR stext = Document. selection. createRange ();
If (stext. Text! = "")
{
Document.exe ccommand ("CreateLink ");
If (stext. parentelement (). tagname = "")
{
Stext. parentelement (). innertext = stext. parentelement (). href;
Document.exe ccommand ("forecolor", false, "# FFFF00 ");
}
}
}
// Obtain blockformats, fill in select (ID is myselect), and change the style according to different blockformats.
// Functions fillselect () and changeformat ()
// Some instructions on Execcommand: executes a command over the given selection or text range
Function fillselect ()
{
VaR item = Document. createelement ("option ")
Item. Text = "select ";
Item. value = "";
Myselect. Add (item );
For (VAR I = 1; I <dlghelper. blockformats. Count; I ++)
{
Item = Document. createelement ("option ");
Item. Text = dlghelper. blockformats (I );
Item. value = dlghelper. blockformats (I );
Myselect. Add (item );
}
}
Function changeformat ()
{
VaR sselect = myselect. Options [myselect. selectedindex]. value;
Document.exe ccommand ("formatblock", false, sselect );
}
// Obtain the drive type, such as showdrivetype ('C :')
Function showdrivetype (drvpath)
{
FS = new activexobject ("scripting. FileSystemObject ");
Disk = FS. getdrive (drvpath );
VaR whichtype = "";
Switch (disk. drivetype)
{
Case 0:
Whichtype = "unknown"
Break
Case 1:
Whichtype = "removable"
Break
Case 2:
Whichtype = "fixed"
Break
Case 3:
Whichtype = "network"
Break
Case 4:
Whichtype = "CD-ROM"
Break
Case 5:
Whichtype = "RAM disk"
}
Alert (whichtype );
// Display the serialnumber of the Disk
Try {
Alert (disk. serialnumber );
}
Catch (e ){
Alert (E. Message );
}
Alert (disk. volumename); // obtain the volume label
}
</SCRIPT>
-------------------------
<Object ID = dlghelper classid = "CLSID: 3050f819-98b5-11cf-bb82-00aa00bdce0b" width = "0px" Height = "0px"> </Object>