Page 1 of 2 12>
Topic Options
#19018 - 2002-03-22 08:30 PM getfileattrib
Anonymous
Unregistered


why when i use the following code:

if getfileattrib ("c:\winnt\system") & 16

does "16" get redirected to the console? it's my understanding that the above line of code is simply asking if "c:\winnt\system" is a directory.

anyone?

Top
#19019 - 2002-03-22 09:13 PM Re: getfileattrib
kholm Offline
Korg Regular
*****

Registered: 2000-06-19
Posts: 714
Loc: Randers, Denmark
You have misspelled the functionname

Should be:
GetFileAttr

Not:
GetFileAttrib

So to check if "c:\winnt\system" is a directory you should write:

If GetFileATTR("c:\winnt\system") & 16

-Erik

Top
#19020 - 2002-03-22 09:15 PM Re: getfileattrib
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
It does a bitwise AND
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#19021 - 2002-03-22 09:22 PM Re: getfileattrib
Anonymous
Unregistered


les_ligetfalvy, how do i get it not to return "16" to the console?

Erik, sorry i mispelled it in my post here. It's spelled correctly in the code. BTW, I would be getting syntax errors if I mispelled it in the script, not a "16".

TIA

Top
#19022 - 2002-03-22 10:22 PM Re: getfileattrib
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Well... there's gotta be a typo somewhere in your code. It shouldn't return anyting to the console. Just to verify, copy paste the following into a separate file and run it.

code:
  
break on
If GetFileATTR("c:\winnt\system") & 16
"It's a folder" ?
endif
Get $_

BTW, what version of KiX and OS?
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#19023 - 2002-03-22 11:07 PM Re: getfileattrib
Anonymous
Unregistered


this is weird. your code snippet worked just fine. I'm running Win2k and Kix 4.02 Here is my exact code. It was written to help counter the W32/MyLife.b@MM virus running around right now:

------------------------------------
$FileFound = 0
$DirFound = 0
$Infected = 0

:Mylifeb
If Exist (%windir%\system\cari.scr)
If GettFileAttr(%windir%\system\cari.scr) & 16
$DirFound = 1
$Result = SetFileAttr(%windir%\system\cari.scr, 5)
$Infected = "not infected"
Else
$FileFound = 1
$Infected = "!INFECTED!"
Endif
Else
Md (%windir%\system\cari.scr)
$Result = SetFileAttr(%windir%\system\cari.scr, 5)
Goto "Mylifeb"
Endif

:Log
$Logfile = "\\clariiweb\logs\logon script logs\Mylifeb.csv"
If RedirectOutput($Logfile, 0) = 0
? "@DATE,@TIME,@WKSTA,$OperatingSystem,@DOMAIN,@IPADDRESS0,$Infected"
Endif

:End
$Result = RedirectOutput("")
------------------------------------

Comments?

Top
#19024 - 2002-03-22 11:27 PM Re: getfileattrib
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
You might want to put your filenames in quotes as in
code:
If GettFileAttr('%windir%\system\cari.scr') & 16 

instead of
code:
If GettFileAttr(%windir%\system\cari.scr) & 16

_________________________
There are two types of vessels, submarines and targets.

Top
#19025 - 2002-03-22 11:28 PM Re: getfileattrib
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
There should be only three T's in GetFileAttr. [Big Grin]

[ 22 March 2002, 23:29: Message edited by: LLigetfa ]
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#19026 - 2002-03-22 11:42 PM Re: getfileattrib
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
I think I need a spell-checker for Kixtart [Wink]
_________________________
There are two types of vessels, submarines and targets.

Top
#19027 - 2002-03-22 11:51 PM Re: getfileattrib
Anonymous
Unregistered


i didn't think putting the quotes would help here, but i tried it nonetheless. the script is still spitting "16" out to the console. thanks for the suggestion though!

i guess it's no big deal, but i'd just like to know where it's coming from and how to stop it. thanks to everyone!

Top
#19028 - 2002-03-23 04:38 AM Re: getfileattrib
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
wakefreak,
Am I invisible here? The problem is your typo on the line:

If GettFileAttr(%windir%\system\cari.scr) & 16

Too many T's in GetFileAttr.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#19029 - 2002-03-23 04:52 AM Re: getfileattrib
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11631
Loc: CA
Planet Earth calling Mr. Invisible - 'come in Mr. Invisible. [Razz]

TTT=(Touch Typing Tutor) comes with a spell checker, or you can download MCA's tools to check those kind of errors.

MCA's place on the Web

[ 23 March 2002, 04:56: Message edited by: NTDOC ]

Top
#19030 - 2002-03-23 04:58 AM Re: getfileattrib
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
NTT DOC,
Whatt do you wantt? Where's tthatt listt of KiX edittors you tthrew ttogetther? Seems Jens and some otthers could sttand tto have some spell checking tto cutt down on erors. [Big Grin] [Big Grin]
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#19031 - 2002-03-23 05:00 AM Re: getfileattrib
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11631
Loc: CA
ROFLMAO

Great reply Les

Top
#19032 - 2002-03-23 08:48 PM Re: getfileattrib
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
OK DOC,
Since you didn't find me that wonderful list you painstakingly put together, I took some of my own advice and searched for it.

BTW, did anyone notice that the search is broken? If you "Search By Registered Member Number", it's likely to come up empty. Wonder how long it's been that way and if Henri knows about it?

Anyway, I finally found it and posted a link to it in the FAQ section.

Can't decide what editor to use... Maybe this'll help

Basically, a dedicated editor would work sorta like a spell checker, at least for all the KiX commands and functions anyway. Hmmm... should I stick with NotePad or switch... [Roll Eyes]
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#19033 - 2002-03-23 09:07 PM Re: getfileattrib
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
LLigetfa, you must be suffering from a case of user error with regard to the "Search By Registered Member Number". It works for me. [Wink]

[ 23 March 2002, 21:11: Message edited by: Howard Bullock ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#19034 - 2002-03-23 09:13 PM Re: getfileattrib
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
LLigetfa:
I don't need a spellchecker, I'm married to one [Wink]
_________________________
There are two types of vessels, submarines and targets.

Top
#19035 - 2002-03-23 10:05 PM Re: getfileattrib
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Jens,
hmmm... what should I infer... you said in your previous post "I think I need a spell-checker for Kixtart"

Are you looking for a new wife or to marry off KiXtart? [Confused]
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#19036 - 2002-03-25 06:22 AM Re: getfileattrib
MCA Offline
KiX Supporter
*****

Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
Dear,

We have trace the exact location which returns "16". It is your line 7.
A bitwise operation with an unknown function name returns an unexpected
result.

Our debugging version:
code:
                                            CLS
COLOR C+/N
AT (1,1) " "
IF RedirectOutput("d:\zszs")
ENDIF
? "-"+LCASE(@day)+" "+@date+" "+@time+"- kixtart "+@kix+"/3.01e script starting."
? "-"
? "-curdir: "+LCASE(@curdir)
? "-scriptdir: "+LCASE(@scriptdir)
? "-startdir: "+LCASE(@startdir)
? "-"
? "-userid: "+LCASE(@userid)+"/"+LCASE(@wuserid)
? "-user priv: "+LCASE(@priv)
? "-version: inwin="+@inwin+"/dos="+@dos
? "-"

?"- 1-"+@time+"- @error @serror "? $filefound = 0
?"- 2-"+@time+"- @error @serror "? $dirfound = 0
?"- 3-"+@time+"- @error @serror "? $infected = 0
?"- 4-"+@time+"- @error @serror "?
?"- 5-"+@time+"- @error @serror "? :mylifeb
?"- 6-"+@time+"- @error @serror "? IF Exist (%windir%\system\cari.scr)
?"- 7-"+@time+"- @error @serror "? IF GetFileAttr(%windir%\system\cari.scr) & 16
?"- 8-"+@time+"- @error @serror "? $dirfound = 1
?"- 9-"+@time+"- @error @serror "? $result = SetFileAttr(%windir%\system\cari.scr, 5)
?"- 10-"+@time+"- @error @serror "? $infected = "not infected"
?"- 11-"+@time+"- @error @serror "? ELSE
?"- 12-"+@time+"- @error @serror "? $filefound = 1
?"- 13-"+@time+"- @error @serror "? $infected = "!INFECTED!"
?"- 14-"+@time+"- @error @serror "? ENDIF
?"- 15-"+@time+"- @error @serror "? ELSE
?"- 16-"+@time+"- @error @serror "? MD (%windir%\system\cari.scr)
?"- 17-"+@time+"- @error @serror "? $result = SetFileAttr(%windir%\system\cari.scr, 5)
?"- 18-"+@time+"- @error @serror "? GOTO "Mylifeb"
?"- 19-"+@time+"- @error @serror "? ENDIF
?"- 20-"+@time+"- @error @serror "?
?"- 21-"+@time+"- @error @serror "? :log
?"- 22-"+@time+"- @error @serror "? $logfile = "\\clariiweb\logs\logon script logs\Mylifeb.csv"
?"- 23-"+@time+"- @error @serror "? IF RedirectOutput($logfile, 0) = 0
?"- 24-"+@time+"- @error @serror "? ? "@DATE,@TIME,@WKSTA,$OperatingSystem,@DOMAIN,@IPADDRESS0,$Infected"
?"- 25-"+@time+"- @error @serror "? ENDIF
?"- 26-"+@time+"- @error @serror "?
?"- 27-"+@time+"- @error @serror "? :end
?"- 28-"+@time+"- @error @serror "? $result = RedirectOutput("")

?"- end-"+@time+"- @error @serror "?
? "-"
? "-"+LCASE(@day)+" "+@date+" "+@time+"- kixtart "+@kix+"/3.01e script ending."
? "-"
;($begin)
;
; mon 25-mar-2002 03:46:36 (kix 4.00 vs 3.01e)
;
;Informative KIXSTRIP: no errors found (input=28 output=28 skip=0).
;
;Informative KIXSTRIP: 3 block_structures found.
;Informative KIXSTRIP: no UDF's found.
;Informative KIXSTRIP: 3 labels found.
;Summary KIXSTRIP: BREAK CALL DEBUG DISPLAY ENDFUNCTION EXECUTE EXIT FUNCTION GET GETS GOSUB GOTO OLExxx PLAY QUIT RETURN RUN SHELL SLEEP THEN USE
;Informative KIXSTRIP: 1 GOTO
;
;($end)

The output of file c:\kixdebug.log is
code:
-monday 2002/03/25 03:47:46- kixtart 4.02/3.01e script starting.
-
-curdir: d:\
-scriptdir:
-startdir: c:\windows
-
-userid: mca/mca
-user priv: guest
-version: inwin=2/dos=4.0
-
- 1-03:47:46- 0 The operation completed successfully.

- 2-03:47:46- 0 The operation completed successfully.

- 3-03:47:46- 0 The operation completed successfully.

- 4-03:47:46- 0 The operation completed successfully.

- 5-03:47:46- 0 The operation completed successfully.

- 6-03:47:46- 0 The operation completed successfully.

- 7-03:47:46- 0 The operation completed successfully.
16
- 8-03:47:46- 0 The operation completed successfully.

- 9-03:47:46- 0 The operation completed successfully.

- 10-03:47:47- 0 The operation completed successfully.

- 11-03:47:47- 0 The operation completed successfully.

- 15-03:47:47- 0 The operation completed successfully.

- 20-03:47:47- 0 The operation completed successfully.

- 21-03:47:47- 0 The operation completed successfully.

- 22-03:47:47- 0 The operation completed successfully.

- 23-03:47:47- 0 The operation completed successfully.

After modifying this line the output becomes:
code:
-monday 2002/03/25 03:51:44- kixtart 4.02/3.01e script starting.
-
-curdir: d:\
-scriptdir:
-startdir: c:\windows
-
-userid: mca/mca
-user priv: guest
-version: inwin=2/dos=4.0
-
- 1-03:51:45- 0 The operation completed successfully.

- 2-03:51:45- 0 The operation completed successfully.

- 3-03:51:45- 0 The operation completed successfully.

- 4-03:51:45- 0 The operation completed successfully.

- 5-03:51:45- 0 The operation completed successfully.

- 6-03:51:45- 0 The operation completed successfully.

- 7-03:51:45- 0 The operation completed successfully.

- 8-03:51:45- 0 The operation completed successfully.

- 9-03:51:45- 0 The operation completed successfully.

- 10-03:51:45- 0 The operation completed successfully.

- 11-03:51:45- 0 The operation completed successfully.

- 15-03:51:45- 0 The operation completed successfully.

- 20-03:51:45- 0 The operation completed successfully.

- 21-03:51:45- 0 The operation completed successfully.

- 22-03:51:45- 0 The operation completed successfully.

- 23-03:51:45- 0 The operation completed successfully.

Some remarks about your code
- the GOTO structure can create a deadlock situation on W9x systems.
in our version we replace this.
- we are using the WriteProfileString function to create only a list
of workstations which are infected. Clean systems will not add to
this list or they will remove from this list.
Our version:
code:
 $entry=ExpandEnvironmentVars("%windir%")+"\system\cari.scr"
:mylifeb
$found="no"
IF Exist($entry) = 1
IF GetFileAttr($entry) & 16
$result=SetFileAttr($entry,5)
ELSE
$found="yes"
ENDIF
ELSE
MD $entry
$result=SetFileAttr($entry, 5)
ENDIF
IF ($found = "yes")
$infected="!INFECTED!"
ELSE
$infected="" ; -not infected-
ENDIF

:log
$logfile = "\\clariiweb\logs\logon script logs\Mylifeb.csv"
$loginfo = "@date @time $OperatingSystem @domain @ipaddress0 $infected"
IF (Len($infected) <> 0)
IF WriteProfileString($logfile,"infected","@wksta",$loginfo)
ENDIF
ELSE
IF WriteProfileString($logfile,"infected","@wksta","")
ENDIF
ENDIF

greetings.

[ 25 March 2002, 07:44: Message edited by: MCA ]
_________________________
email scripting@wanadoo.nl homepage scripting@wanadoo.nl | Links | Summary of Site Site KiXforms FAQ kixtart.org library collection mirror MCA | FAQ & UDF help file UDF kixtart.org library collection mirror MCA | mirror USA | mirror europe UDF scriptlogic library collection UDFs | mirror MCA

Top
#19037 - 2002-03-25 06:30 AM Re: getfileattrib
MCA Offline
KiX Supporter
*****

Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
Dear NTDOC,

This topic inspires me to extend the kixstrip tool. Undefined or defined functions
doesn't inform me about possible problems.
The extension will report all names which aren't defined by KiXtart. So above mistyping will
also be reported.

Hey Les,

When do you get a new keyboard? Your letter "T" doesn't work great anymore.

greetings.

[ 25 March 2002, 06:31: Message edited by: MCA ]
_________________________
email scripting@wanadoo.nl homepage scripting@wanadoo.nl | Links | Summary of Site Site KiXforms FAQ kixtart.org library collection mirror MCA | FAQ & UDF help file UDF kixtart.org library collection mirror MCA | mirror USA | mirror europe UDF scriptlogic library collection UDFs | mirror MCA

Top
Page 1 of 2 12>


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 595 anonymous users online.
Newest Members
ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder, M_Moore
17887 Registered Users

Generated in 0.071 seconds in which 0.026 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org