Jump to content

is it a bug in "FileFindFirstFile" when searching on hidden shares?


Recommended Posts

Hello, I'm facing a strange problem, can someone give me a tip on how to solve this?

If I put the script on the the same path as the ini files, this works ok!

$search = FileFindFirstFile("\\server\share$\*.ini")

if I put it on another path, it doesn't return anything; the behavior is the same if I use the "\\server\share$" path or not...

[topic="51913"]Restrict USB Storage usage to group membership[/topic] * [topic="48699"]Using nircmd library[/topic] * Some admin notes

Link to comment
Share on other sites

Hi BullGates,

what happens when you open a command box and type

dir \\server\share$\*.ini

Do you get a result?

A-Jay

Rule #1: Always do a backup         Rule #2: Always do a backup (backup of rule #1)

Link to comment
Share on other sites

FileFindFirstFile() returns a handle. So does the handle equal -1? or some other error condition? Your explanation seems unclear to determine. Perhaps the issue is one of the other lines in the script that is not shown.

Link to comment
Share on other sites

FileFindFirstFile() returns a handle. So does the handle equal -1? or some other error condition? Your explanation seems unclear to determine. Perhaps the issue is one of the other lines in the script that is not shown.

Hello, it returns 2. The same code works great if I put the script on the same directory as the ini files. This is quite strange.

Here goes all the code, it calculates how often users use office products, by processing the data that other script sends to an hiden share.

$dados = FileOpen("dados.csv", 2)
If $dados = -1 Then
    MsgBox(0, "Erro", "Ficheiro em uso, por favor feche e tente de novo.")
    Exit
EndIf
$procura = FileFindFirstFile("\\server\share$\*.ini")
ConsoleWrite("User,Access,Excel,Outlook,Winword" & @CRLF)
FileWriteLine($dados,"User;Access;Excel;Outlook;Winword" & @CRLF)
While 1
    $inifile = FileFindNextFile($procura)
    If @error Then ExitLoop
    $computador = IniReadSectionNames($inifile)
    Dim $access[$computador[0] + 1]
    Dim $excel[$computador[0] + 1]
    Dim $outlook[$computador[0] + 1]
    Dim $winword[$computador[0] + 1]
    For $i = 1 To $computador[0]
        $access[$i] = IniRead($inifile, $computador[$i], "Access", 0)
        $excel[$i] = IniRead($inifile, $computador[$i], "Excel", 0)
        $outlook[$i] = IniRead($inifile, $computador[$i], "Outlook", 0)
        $winword[$i] = IniRead($inifile, $computador[$i], "Winword", 0)
    Next
    $access1 = 0
    $excel1 = 0
    $outlook1 = 0
    $winword1 = 0
    For $i = 1 To $computador[0]
        $access1 = $access[$i] + $access1
        $excel1 = $excel[$i] + $excel1
        $winword1 = $winword[$i] + $winword1
        $outlook1 = $outlook[$i] + $outlook1
    Next
    $utilizador = StringTrimRight($inifile, 4)
    ConsoleWrite($utilizador & ";" & $access1 & ";" & $excel1 & ";" & $outlook1 & ";" & $winword1 & @CRLF)
    FileWriteLine($dados,$utilizador & ";" & $access1 & ";" & $excel1 & ";" & $outlook1 & ";" & $winword1 & @CRLF)
WEnd
FileClose($procura)
FileClose($dados)
FileClose($inifile)

ShellExecute("dados.csv")
Edited by BullGates

[topic="51913"]Restrict USB Storage usage to group membership[/topic] * [topic="48699"]Using nircmd library[/topic] * Some admin notes

Link to comment
Share on other sites

Hello, it returns 2. The same code works great if I put the script on the same directory as the ini files. This is quite strange.

Here goes all the code, it calculates how often users use office products, by processing the data that other script sends to an hiden share.

Thanks for the information. I see your issue. You are using $inifile as a path for IniReadSectionNames(). $inifile is just a filename returned from FileFindNextFile(), not a full path and the filename.

A quick fix is to build a full path adding a line of code as below.

While 1
    $inifile = FileFindNextFile($procura)
    If @error Then ExitLoop
    $inifile = '\\server\share$\' & $inifile ; make a full path

That should help :(

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...