Sign in to follow this  
Followers 0
cdnnewbie

Array Help

9 posts in this topic

OK heres the deal. I am doing a file comparison between 2 files below is the script

dim $l[10], $s[10]

$L = FileGetTime ("c:\update\defmsp.exe" ,1)

$S = FileGettime ("\\netadmin02\netlogon\defmsp.exe" ,1)

$fd = $l[0] & $l[1] & $l[2]

$fd2 = $s[0] & $s[1] & $s[2]

Run (@SystemDir & "\net.exe time /domain:ABC /set","")

Filecopy("\\server\netlogon\defmsp.exe", "C:\update", 1, @sw_MINIMIZE)

If FileExists("c:\update\defmsp.exe") = 1 then

if $fd < @fd2 then

SplashTextOn("Please wait...", "Command Antivirus is currently updating.", 350, 25, -1, -1, 0, "", 12)

sleep(2000)

SplashOff()

Filecopy("\\server\netlogon\defmsp.exe", "C:\update", @sw_MINIMIZE)

sleep(1000)

Runwait ("c:\update\defmsp.exe", "c:\update", @sw_MINIMIZE)

sleep(1000)

Filecopy("C:\update\*.msp", "c:\update\update.msp", @sw_MINIMIZE)

RunWait(@ComSpec & " /c " & "c:\update\update.msp /q", "C:\WINNT", @sw_MINIMIZE)

FileDelete("C:\update\*.MSP")

endif

else

SplashTextOn("Please wait...", "Command Antivirus is currently updating.", 350, 25, -1, -1, 0, "", 12)

sleep(2000)

SplashOff()

Filecopy("\\server\netlogon\defmsp.exe", "C:\update", @sw_MINIMIZE)

sleep(1000)

Runwait ("c:\update\defmsp.exe", "c:\update", @sw_MINIMIZE)

sleep(1000)

Filecopy("C:\update\*.msp", "c:\update\update.msp", @sw_MINIMIZE)

RunWait(@ComSpec & " /c " & "c:\update\update.msp /q", "C:\WINNT", @sw_MINIMIZE)

FileDelete("C:\update\*.MSP")

endif

When I run the above I am getting an error stating - Error:Subscript used with non-array variable

:huh2::D


[quote]He who smiles in a crisis has found someone to blame[/quote]

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

dim $l[10], $s[10]

$L = FileGetTime ("c:\update\defmsp.exe" ,1)

$S = FileGettime ("\\netadmin02\netlogon\defmsp.exe" ,1)

$fd = $l[0] & $l[1] & $l[2]

$fd2 = $s[0] & $s[1] & $s[2]

The FileGetTime function will overwrite $L and $S whether they are declared as arrays. You should check @error or check UBound($L) to see if the FileGetTime succeeded. If FileGetTime fails, the return value will not be an array. Even if FileGetTime succeeds, the resulting array will only contain elements 0 to 5.

$L = FileGetTime ("c:\update\defmsp.exe" ,1)
If @error Then
  MsgBox(4096,"Error", "file not found...")
   Exit
EndIf
$S = FileGettime ("\\netadmin02\netlogon\defmsp.exe" ,1)
If @error Then
  MsgBox(4096,"Error", "file not found...")
   Exit
EndIf
$fd = $l[0] & $l[1] & $l[2]
$fd2 = $s[0] & $s[1] & $s[2]

Hope that makes sense

Edited by CyberSlug

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

Share this post


Link to post
Share on other sites

dim $l[10], $s[10]

$L = FileGetTime ("c:\update\defmsp.exe" ,1)

$S = FileGettime ("\\netadmin02\netlogon\defmsp.exe" ,1)

$fd = $l[0] & $l[1] & $l[2]

$fd2 = $s[0] & $s[1] & $s[2]

Why do you dimention it and then redim it from the function?

also, I would put a check to see that FileGetTime returned an array.

$L = FileGetTime ("c:\update\defmsp.exe" ,1)
$S = FileGettime ("\\netadmin02\netlogon\defmsp.exe" ,1)
if NOT isarray("L") then msgbox(1,"error","c:\update\defmsp.exe not found")
if NOT isarray("s") then msgbox(1,"error","\\netadmin02\netlogon\defmsp.exe not found")
    If NOT isarray("L") or NOT isarray("s") Then exit
$fd = $l[0] & $l[1] & $l[2]
$fd2 = $s[0] & $s[1] & $s[2]

AutoIt3, the MACGYVER Pocket Knife for computers.

Share this post


Link to post
Share on other sites

ok I ran the one from cyber slug and its saying the file is not found. So with this question answered whats do i do to fix it...


[quote]He who smiles in a crisis has found someone to blame[/quote]

Share this post


Link to post
Share on other sites

That means one of the two files referanced from the time command is not beeing seen by AutoIt. Check that they both exist, and they you have proper network premissions for the remote file.


[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Share this post


Link to post
Share on other sites

:D

would help if the defmsp.exe was on the local machine so that something could be compared


[quote]He who smiles in a crisis has found someone to blame[/quote]

Share this post


Link to post
Share on other sites

I have kind of the same problem.

The problem is that I cannot use FileGetTime on a file that reside on a shared folder on the network even if I map the shared folder as a drive. I tested the following code to see if it might be related to the fact that the drive was in NTFS.

MsgBox ( 1, "NTFS", "DriveStatus = " & DriveStatus("T:\") & @CRLF & "FileExists = " & FileExists("T:\file.txt") & @CRLF & "FileGetTime = " & FileGetTime("T:\file.txt", 0) & @CRLF)

MsgBox ( 1, "FAT32", "DriveStatus = " & DriveStatus("M:\") & @CRLF & "FileExists = " & FileExists("M:\file.txt") & @CRLF & "FileGetTime = " & FileGetTime("M:\file.txt", 0) & @CRLF)

The T drive is a NTFS drive and permission are set so that the "everyone" user account has "Full Control"

The M drive is a FAT32 drive and permission are set so that anyone can write without any password authentification.

In both cases, I get the following:

DriveStatus = READY

FileExists = 1

FileGetTime =

So it seem to me like it's either a AutoIT3 Bug or an AutoIT3 limitation, but I would like for someone else's opinion before logging it as such.

If anyone can use FileGetTime on a file residing on a network shared folder, please reply so that I can understand what you did differently and that I can adjust my scripts accordingly.

Thanks!

Share this post


Link to post
Share on other sites

The FileGetTime returns an Array so don't think your example msgboxes would work on any file....

this should work (Didn't test it on network drives):

$t =  FileGetTime("C:\Windows\Notepad.exe", 1)
If Not @error Then
    $ymd = $t[0] & "/" & $t[1] & "/" & $t[2] & " " & $t[3] & ":" & $t[4] & ":" & $t[5]
    MsgBox ( 1, "NTFS", "DriveStatus = " & DriveStatus("c:\") & @CRLF & "FileExists = " & FileExists("C:\Windows\Notepad.exe") & @CRLF & "FileGetTime = " & $YMD & @CRLF)
EndIf

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Thanks JdeB

That was a dumb mistake on my part.

I have rewrote your code to test on mapped network shared folders:

$t = FileGetTime("T:\file.txt", 1)

If Not @error Then

$ymd = $t[0] & "/" & $t[1] & "/" & $t[2] & " " & $t[3] & ":" & $t[4] & ":" & $t[5]

MsgBox ( 1, "NTFS", "DriveStatus = " & DriveStatus("T:\") & @CRLF & "FileExists = " & FileExists("T:\file.txt") & @CRLF & "FileGetTime = " & $YMD & @CRLF)

EndIf

...and it works!

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0