Jump to content

Data Security Product conflict with INIWRITE function


Recommended Posts

OK here's an odd one... I have installed a data security product called Vormetric on my Windows 2008R2 server and afterward the iniwrite function no longer works.  If I uninstall it then iniwrite once agains functions as expected.  Interestingly enough Fileopen and Filewrite work regardless of whether or not Vormetric is installed.  Does anyone have any idea what the INIWRITE function is doing behind the scenes?  That may help me understand why Vormetric is stopping it from working.  Below is a test script I use to verify functionality.

 Thanks in advance for any help you can offer. :)

 

$strTemp1 = "test text"
$strTemp2 = "test text 2"
$hdlFile = FileOpen("C:\test.txt",2)

$strTemp = FileWrite($hdlFile,$strTemp1)
MsgBox(0,"",$strTemp) ;shows a 1 which means success

$strTemp = FileClose($hdlFile)
MsgBox(0,"",$strTemp) ;shows a 1 which means success

$strTemp = IniWrite("C:\test.txt", "Section1", "Value", $strTemp2 )
MsgBox(0,"",$strTemp) ;shows a 0 which means failure

 

Link to comment
Share on other sites

Thank for the quick reply Jos.  Ok so when I call the api directly it still doesn't work on my server with Vormetric installed.  The code below does work on a server without Vormetric.  Interestingly enough it will create the .ini file if it doesn't exist but it won't write anything in the file.  I'll likely have to call the fine folks at Vormetric to get to the bottom of this unless anyone else has any ideas.

 

 

#include <Array.au3>
$arrTemp = DllCall("kernel32.dll", "int", "WritePrivateProfileString", "str", "Section1","str","Value","str","Value1","str","c:\test.ini")
_ArrayDisplay($arrTemp)

 

Link to comment
Share on other sites

how about on a file that is not in the root of c:\  ?

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

 I've tried writing to an .ini file in different locations without success.

Filewrite by itself works as it should.

When I use the _WinAPI_GetLastError ( ) function after the iniwrite attempt I get an error 33 which is "The process cannot access the file because another process has locked a portion of the file."  I've confirmed this while using Process Monitor which shows the file creation as successful but the filewrite operation fails.

My guess is that the iniwrite/WritePrivateProfileString functions create a file, write to the file, and try to save the file in 1 operation and in the middle of this sequence Vormetric is getting involved and locking the file.  It's still confusing because I'd guess that is the same sequence that Filewrite is doing.

Oh well I'll see what Vormetric has to say about this.

Thanks all for your help.

 

Link to comment
Share on other sites

And try FileWrite without FileOpen, does thAT WORK?

You cannot FileWrite() without first obtaining a handle via FileOpen().

 I've tried writing to an .ini file in different locations without success.

Filewrite by itself works as it should.

When I use the _WinAPI_GetLastError ( ) function after the iniwrite attempt I get an error 33 which is "The process cannot access the file because another process has locked a portion of the file."  I've confirmed this while using Process Monitor which shows the file creation as successful but the filewrite operation fails.

My guess is that the iniwrite/WritePrivateProfileString functions create a file, write to the file, and try to save the file in 1 operation and in the middle of this sequence Vormetric is getting involved and locking the file.  It's still confusing because I'd guess that is the same sequence that Filewrite is doing.

Oh well I'll see what Vormetric has to say about this.

Thanks all for your help.

 

I would contact Vormetric as well. You mentioned in your OP that it is a Data Security software. Have you tired whitelisting (adding an exception) to the directory of the ini file you are trying to write?

 

 

Link to comment
Share on other sites

There is no mention that the OP needs to append data.

I literally copy-paste from the documentation. Idk why it says "to the end" when it can write in several different modes. Another case where the documentation is out of date. For starters, FileOpen() is what sets the Read/Write mode, so it is false to assume that Append was used automatically, like it was in the documentation.

Edited by BetaLeaf

 

 

Link to comment
Share on other sites

Betaleaf - from the Help file for FileWrite...

The handle of a file, as returned by a previous call to FileOpen(). Alternatively, you may use a string filename as the first parameter

I agree there is some inconsistency. 

Edited by kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Link to comment
Share on other sites

There's no inconsistency, it's just written poorly. It is trying to say; if you use a file handle on a file that was opened in read only mode it will fail if you try to write to it.

It also clearly states this in the help file:

If a filename is given rather than a file handle, the file will be opened and closed during the function call. For parsing large text files this will be much slower than using filehandles. However, filename will be created if it does not already exist.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

I would also go as far as to say that it would only be "much slower" if the file is being parsed in a loop.

I imagine FileOpen, FileRead, FileClose for the whole contents is the same as FileRead alone.

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

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