mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Dec 2002
Posts: 580
N
Fjord artisan
OP Offline
Fjord artisan
N
Joined: Dec 2002
Posts: 580
(a user of my scripts reported this to me)

Apparently MS Spyware has problems when I use .wsf files to do a sleep (containing WScript.Sleep). Can $com be used directly to sleep scripts, rather than using .wsf files and $com(WScript.Shell, Run, ...). Or is there a $dll (with source prefered) that can do it?

Joined: Dec 2002
Posts: 1,245
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Dec 2002
Posts: 1,245
one question is: is it the ".wsf file" that its triggering on, or the content?

A simple name change might solve the problem

Joined: Feb 2004
Posts: 2,013
F
Hoopy frood
Offline
Hoopy frood
F
Joined: Feb 2004
Posts: 2,013
It's because it's a .wsf file. That spyware detector will detect it if any script file is being run. This includes files like:

.wsf
.vbs
.js
.bat

etc.

The snippet needs to be a .vbs/.js/.wsf as the code depends on those script interpreters.

There is a way to have a sleep command without needing a file. Fortunately it relies on using a hack on a command line utility that should be in any Windows version that came with TCP/IP, more specifically pathping.exe. Hopefully it works the same way it does as in Windows XP, or I can't guarantee it would still work. It's particularly funny that I use pathping.exe for a /pause command, but it was simply the only dos utility that comes with Windows that I could find, that let's me specify an interval in milliseconds. A version that I was making prior to this one was using ping.exe, but that only lets you specify seconds for intervals.

/*

Usage: /pause <milliseconds>

Examples:

//var %ticks = $ticks | pause 1500 | echo -a Paused for: $calc($ticks - %ticks)
//pause 3000 | echo -a Hi there

Note it is not to be used with values under 100. You can, but it will pause 100 ticks too long, and isn't very accurate. So /pause 30 will pause for 125-130 milliseconds instead, nothing I can do about that.

Note that with higher intervals, there will sometimes be a small deviation from the value you specified, fex in the example where you pause for 1500 milliseconds, it sometimes pauses for 1515 milliseconds, so 15 milliseconds too much, although often it is right on the spot.

If you want for something beneath 100 milliseconds to pause you should just do:

//var %a = $ticks + 100 | while ($ticks < %ticks) ! | ...

Although I mention these deviations, note that with the original alias with the .wsf file that you are using, the deviation is much greater, so this alias scores better in terms of accuracy, whilst not needing to do any file access, or triggering Spyware detectors.

*/

Code:
alias pause {
  if ($1 !isnum 1-) return
  var %wsh = wsh $+ $ticks
  .comopen %wsh wscript.shell
  .comclose %wsh $com(%wsh,run,1,bstr*,% $+ comspec% /c pathping -n -w 1 -q 1 -h 1 -p $iif($1 &gt; 100,$calc($1 - 100),$1) localhost &gt;nul,uint,0,bool,true)
}


Joined: Feb 2004
Posts: 2,013
F
Hoopy frood
Offline
Hoopy frood
F
Joined: Feb 2004
Posts: 2,013

  • Some amendments/corrections to my previous post:
  • Had specified the wrong variable in this example:

    //var %ticks = $ticks + 100 | while ($ticks < %ticks) ! | ...
  • The % $+ comspec% /c part and > nul parts aren't needed and it's slightly better to use 127.0.0.0 instead of local host therefore the new version:

    Code:
    alias pause {
      if ($1 !isnum 1-) return
      var %wsh = wsh $+ $ticks
      .comopen %wsh wscript.shell
      .comclose %wsh $com(%wsh,run,1,bstr*,pathping.exe -n -w 1 -q 1 -h 1 -n -p $iif($1 &gt; 40,$calc($1 - 40),$1) 127.0.0.0,uint,0,bool,true)
    }
  • The /pause snippet doesn't work on Windows 98/ME, nothing I can do, it needs pathping.exe which was only included from Windows 2000 on.
  • I might as well post the version that used ping.exe but only supports seconds, since that does work on 98:

    Code:
    alias pause2 {
      if ($1 !isnum 1-) return
      var %wsh = wsh $+ $ticks
      .comopen %wsh wscript.shell
      .comclose %wsh $com(%wsh,run,1,bstr*,ping.exe -n $int($calc($1 + 1)) 127.0.0.1,uint,0,bool,true)
    }


    Thanks to Online for some feedback.

Joined: Feb 2004
Posts: 2,013
F
Hoopy frood
Offline
Hoopy frood
F
Joined: Feb 2004
Posts: 2,013
For anyone interested, I have submitted a snippet using the techniques presented here by myself, which you can find here:

/pause


Link Copied to Clipboard