Jump to content

Recommended Posts

Posted

Code is below. I've used every command in other scripts without problem but, for some reason, this one crashes the compiler every time. CheckRun works fine and all syntax seems good.

Ideas?

(Any tweaking suggestions are also welcome)

global $AAW = @ProgramFilesDir & '\Lavasoft\Ad-aware 6\Ad-aware.exe'
global $SBSD = @ProgramFilesDir & '\Spybot - Search & Destroy\SpybotSD.exe'
Global $SWB = @ProgramFilesDir & '\SpywareBlaster\spywareblaster.exe'
Global $SWGU = @ProgramFilesDir & '\SpywareGuard\sgliveupdate.exe'
Global $file
Global $job

;clear old AT tasks
RunWait(@ComSpec & " /c at /delete /yes", "", @SW_HIDE)

$OS = @OSVersion
If $OS = "Win_98" Or $OS = "Win_ME" Or $OS = "Win_95" Then Win9x()
If $OS = "Win_XP" Then winxp()
Exit

Func Win9x()
$job="Spybot - Search & Destroy.job"
global $file = $SBSD
Makejob()
$job="Ad-Aware.job"
Global $file = $AAW
Makejob()
$job="SpywareBlaster.job"
Global $file= $SWB
Makejob()
$job="SpywareGuard Update.job"
Global $file = $SWGU
makejob()
EndFunc

;copies saved .job files from a storage directory to the system's Task folder
Func Makejob() 
If FileExists($file) then FileInstall("F:\Spyware\" & $job, @WindowsDir & "\tasks\" & $job)
EndFunc

Func Winxp()
if FileExists($AAW) then  RunWait(@ComSpec & ' /c at 20:00 /every:Th ' & $AAW, "", @SW_HIDE)
if FileExists($SWGU) then RunWait(@ComSpec & ' /c at 20:01 /every:1 ' & $SWGU, "", @SW_HIDE)
if FileExists($SBSD) then RunWait(@ComSpec & ' /c at 20:02 /every:F ' & $SBSD, "", @SW_HIDE)
if FileExists($SWB) then  RunWait(@ComSpec & ' /c at 20:03 /every:F ' & $SWB, "", @SW_HIDE)
EndFunc
  • Developers
Posted (edited)

If FileExists($file) then FileInstall("F:\Spyware\" & $job, @WindowsDir & "\tasks\" & $job)

<{POST_SNAPBACK}>

You cannot have a variable in the fileinstall source!!.

But it shouldn't do kabooom....

Edited by JdeB

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Posted (edited)

What is the error?

Edit: From the help file.

Source: The source path of the file to compile. This must be a literal string; it cannot be a variable.

Dest: The destination path with trailing backslash. This can be a variable.

Edited by Burrup

qq

  • Developers
Posted

What is the error?

Edit: From the help file.

Source: The source path of the file to compile. This must be a literal string; it cannot be a variable.

Dest: The destination path with trailing backslash. This can be a variable.

<{POST_SNAPBACK}>

Its a Hard Crash on Win98 with 3.1.1:

AUT2EXE caused an invalid page fault in

module AUT2EXE.EXE at 017f:0040896b.

Registers:

EAX=69460020 CS=017f EIP=0040896b EFLGS=00010246

EBX=00000001 SS=0187 ESP=0065d280 EBP=0065e7a4

ECX=00000000 DS=0187 ESI=00000006 FS=1b7f

EDX=7efefeff ES=0187 EDI=0065d2b5 GS=0000

Bytes at CS:EIP:

8b 01 03 d0 83 f0 ff 33 c2 8b 11 83 c1 04 a9 00

Stack dump:

0041a640 00402923 0065d29c 00000000 bff779ae 0041a640 00417c20 706d6f43 73736572 20676e69 20646e61 69646461 203a676e 69460020 6e49656c 6c617473

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Posted (edited)

A little trial and error showed that this line was causing the compiler to crash:

If FileExists($file) then FileInstall("F:\Spyware\" & $job, @WindowsDir & "\tasks\" & $job)

LOL -- I just noticed that since I posted this a few minutes ago, there's already been 2 replies. Wow. Thanks, guys. I hope that if I'd stared at that line for a little longer the variable/string problem would've come to light.

Ok, since I can't use F:\Spyware\" & $job to point to my files, I suppose I'll have to forego the use of the makejob() function. Any suggested shortcuts?

Edited by Xander
Posted (edited)

Maybe AutoIt should check it first? With a much simpler error message, "You can't have a variable for the 'source' in the FileInstall() function.".

Or perhaps as its already mentioned in the helpfile you would assume people have read it and fully understand it limitations.

Edit: Or, maybe I'm hoping to much, AutoIt should be able to detect if a function will only be called after another function. eg.

MyFunc2()

Func MyFunc1()
 ;Blah
EndFunc

Func MyFunc2()
 ;Blah
   MyFunc1()
EndFunc

As seen in the above example of this, not mine, that the function MakeJob() is only called after the variable is set for using the FileInstall() in it, is set with the Win9x() function.

To hard?

Edited by Burrup

qq

Posted

I know, Burrup.

As a newbie to the language, I have read the help file but had only just realized wherein my problem was lying. Also sometimes a matter of building up habits, right? I might know the theory but forget it in the heat of the moment.

Jdeb, just a soft crash with WinXP. The debugging info that comes from it is next to useless but, now that the line itself has been identified, it should just be a matter of fiddling with the code.

I originally had the codes all full of nearly-identical literal strings but got the bright idea of making a function out of them and trying to streamline.

I've got it down to:

Func Win9xtasks()
If FileExists($SBSD) then FileInstall("F:\Spyware\Spybot - Search & Destroy.job", @WindowsDir & "\tasks\Spybot - Search & Destroy.job")
If FileExists($AAW) then FileInstall("F:\Spyware\Ad-Aware.job", @WindowsDir & "\tasks\Ad-Aware.job")
If FileExists($SWB) then FileInstall("F:\Spyware\SpywareBlaster.job", @WindowsDir & "\tasks\SpywareBlaster.job")
If FileExists($SWGU) then FileInstall("F:\Spyware\SpywareGuard Update.job", @WindowsDir & "\tasks\SpywareGuard Update.job")
EndFunc

...which might be the leanest I can get it, under the circumstances.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...