Jump to content

Recommended Posts

Posted

I have a very simple ini-Files:

 

[variables]

testentry="successful"

 

my attempt to read the line:

$initest = IniRead($ini, "variables", "testentry", "failed")

 

That worked fine for a while. Now we got a new server and for some reason, IniRead can no longer access the file.

Unfortunately IniRead has no error-flags, so I currently have no idea what might be the problem.

I can access the ini-file by windows, so I am not missing access rights.

 

Does anyone have an idea?

TG

Posted

$ini is just the path to the server, "\\servername\share\ini\test.ini"

I tried to get enerything as basic as possible, so I stripped everything I found not connected to the issue.

Everything worked till the server was replaced by another one, but from what I checked so far, the permissions and all shares were cloned from the old one.

 

Posted

Please do a test with :

#include <Array.au3>
Local $sIniFile, $aSections, $initest
$sIniFile = "\\servername\share\ini\test.ini" 

; TEST : adding a FileExists with the same path just before reading :
If FileExists($sIniFile) Then
    MsgBox(BitOR(4096, 64), "Message :", "File found" & @CRLF)
Else
    MsgBox(BitOR(4096, 16), "Message :", "ERROR : File not found" & @CRLF)
    Exit
EndIf

; TEST : try to read all section names in the ini file :
$aSections = IniReadSectionNames($sIniFile)
_ArrayDisplay($aSections, "1. Sections :")

; read value :
$initest = IniRead($sIniFile, "variables", "testentry", "failed")
MsgBox(BitOR(4096, 64), "Message :", "Value = " & $initest & @CRLF)

 

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Posted

Try another function fileread to see if that works

 

#include <FileConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>

Example()

Func Example()
    ; Create a constant variable in Local scope of the filepath that will be read/written to.
    Local Const $sFilePath = "\\servername\share\ini\test.ini"

    ; Open the file for reading and store the handle to a variable.
    Local $hFileOpen = FileOpen($sFilePath, $FO_READ)
    If $hFileOpen = -1 Then
        MsgBox($MB_SYSTEMMODAL, "", "An error occurred when reading the file.")
        Return False
    EndIf

    ; Read the contents of the file using the handle returned by FileOpen.
    Local $sFileRead = FileRead($hFileOpen)

    ; Close the handle returned by FileOpen.
    FileClose($hFileOpen)

    ; Display the contents of the file.
    MsgBox($MB_SYSTEMMODAL, "", "Contents of the file:" & @CRLF & $sFileRead)

EndFunc   ;==>Example

 

Posted
On 11/22/2021 at 3:17 PM, Togego said:

$ini is just the path to the server, "\\servername\share\ini\test.ini"

I tried to get enerything as basic as possible, so I stripped everything I found not connected to the issue.

Everything worked till the server was replaced by another one, but from what I checked so far, the permissions and all shares were cloned from the old one.

 

what is the OS version of the old server and what is the OS version of the new server?
Also what is the OS version of the system used to run the script?

 

  • 3 weeks later...
Posted

Sorry for the delay, I got busy on another project.

The Problem was indeed the access to the share. While it should have been a clone, it was done manually and the person accidently switched two numbers.

So no problem with iniread at all.

Thanks everyone!

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
  • Recently Browsing   0 members

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