Jump to content
Sign in to follow this  
DirtyMonkeyXXX

File Editing in Windows 7

Recommended Posts

DirtyMonkeyXXX

Hi,

Where I work, we use a boatload of AutoIt scripts to do prerequisite installs, so if an app needs a special driver or add on software, we have an AutoIt script to install said driver/app. Since we've started receiving some Win7 PCs, I've been working to update our scripts to be a little more robust (they were mostly hard coded for Windows XP systems). Most of them have converted fine, but I've run into a slight issue.

We have a package that installs an Oracle 10g client on the users machine. This package works fine and installs the client flawlessly. We have a few other packages that go through and update the TNSnames.ora file in the Oracle client's repository. Here's a snippet of the code:

$file = FileOpen($oraHome & "\NETWORK\ADMIN\TNSNAMES.ORA", 1)
FileWriteLine($file, "#BEGIN Added by Package")
FileWriteLine($file, $DB_Name & " = ")
;...(more FileWriteLines)
FileWriteLine($file, "#END Added by Package")
FileClose($file)

The issue I'm running into is that AutoIt can't open the file for writing. As a matter of fact, neither can I. If I double click the file and open it normally in Notepad, I can't save changes. From what I've read and tried, Notepad needs to be running as Administrator to change the file because of the way its set up. I've added "#RequireAdmin" to the script, and when running it does prompt me for administrative privileges (I'm running as a local administrator, btw). But it is still unable to open the file successfully.

I've tried AutoIt 3.3.4.0 and just updated to 3.3.6.1, which didn't help. So any suggestions on modifying the file? Perhaps changing the security on the file? I saw a post about using @ComSpec to echo one file into another, but I don't know how well that works when appending to an existing file.

Let me know if you need more info. Thanks in advance!

Chris

Share this post


Link to post
Share on other sites
DirtyMonkeyXXX

I apologize profusely. My path variable to the file was garbage and I didn't verify it was correct before posting.

Fixing the path fixed the problem, so no more issue.

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  

×