WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: bettman on November 09, 2016, 04:51:08 AM

Title: Modifying an ini file in the Windows directory
Post by: bettman on November 09, 2016, 04:51:08 AM
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.
Title: Re: Modifying an ini file in the Windows directory
Post by: td on November 09, 2016, 08:08:40 AM
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.
Title: Re: Modifying an ini file in the Windows directory
Post by: bettman on November 09, 2016, 09:25:03 AM
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.
Title: Re: Modifying an ini file in the Windows directory
Post by: td on November 09, 2016, 10:52:05 AM
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   (http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/nftechsupt.web+WinBatch/64-bit+File~Redirection.txt)