code:
var SLEEP_TIMEOUT = 200;
var WAIT_RUN_TIMEOUT = 20000;
//
var WshShell = new ActiveXObject("WScript.Shell");
var Drivers = GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery("select * from Win32_SystemDriver where Name=\'Haspnt\'");
if ( Drivers.Count < 1 )
{
WshShell.Popup("HASP driver not installed", 0, "Error", 16);
WScript.Quit(2);
}
var e = new Enumerator(Drivers);
e.moveFirst();
var haspdrv = e.item();
var wait_time = 0;
while ( haspdrv.State != "Running" )
{
WScript.Sleep( SLEEP_TIMEOUT );
wait_time = wait_time + SLEEP_TIMEOUT;
if ( wait_time > WAIT_RUN_TIMEOUT ) break;
}
if ( haspdrv.State == "Running" )
{
WshShell.Run("C:\\Trace.lnk ");
}
else
{
WshShell.Popup("HASP driver can't started, Trace Mode 6 not running", 0, "Error", 16);
}