Jump to content

IniRead can't access ini-file on UNC-path


Togego
 Share

Recommended Posts

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

Link to comment
Share on other sites

Sorry crystal ball is at repair shop.  You may want to tell us with is the exact content of $ini.  Even with it, not sure if anyone can help you, but you give yourself a chance...

Link to comment
Share on other sites

$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.

 

Link to comment
Share on other sites

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."

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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?

 

Link to comment
Share on other sites

  • 3 weeks later...

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!

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...