Modifying an ini file in the Windows directory

Started by bettman, November 09, 2016, 04:51:08 AM

Previous topic - Next topic

bettman

Greetings,

Is it possible to modify an ini file in the Windows directory (C:\Windows\System32\GroupPolicy\Machine\Scripts\scripts.ini)? I've tried everything I can think of, including compiling the script and running it as admin with no success.

Any help would be appreciated.

td

Certainly possible.  You need to check the permissions using the Network extender,  the Explorer shell, calcs.exe, or icalcs.exe and act accordingly. You may need to change ownership in order to change permissions on the file.  The the Network extender or takeown.exe can be used for that.  You may also want to use the FileLockItemize function to determine if the file is opened and locked by another process. If that is the case, the only solution is to kill the process locking the file if possible.

Keep in mind that  'running it as admin' may not be sufficient to execute a script with full admin privileges in a UAC environment.   If you haven't already, compile the script as 'requireAdministrator' (or even 'highestAvailable' if the plan is to run the script from an administrator account)  to test this possibility.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

bettman

Hi,

Thank you for the information. I should have mentioned that I can edit/modify/delete the file outside of Winbatch without any difficulty. As a quick test, I inserted FileDelete("C:\Windows\System32\GroupPolicy\Machine\Scripts\scripts.ini") into the script and it did not delete the file. I even went so far as to take ownership of the file with no success. In addition, I did compile the script as 'requireAdministrator' and 'highestAvailable. FYI, I am using WB2015B on Windows 7 x64 as my testing platform.

Thank you.

td

Adding the important details makes it easier to narrow down the problem and assuming you are using 32-bit WinBath, it  sound like a file redirection issue.  Please read the following Tech Database article:

http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/nftechsupt.web+WinBatch/64-bit+File~Redirection.txt 
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade