Page 1 of 1

How to [automatically] rename a file within a non-specified subfolder? [AKA stopping Opera from autoupdating]

Posted: 24 Oct 2022 14:00
by DOSadnie
The Opera web-browser has this nasty habit of turning on automatic updates without user's consent. The quickest way to disable them is to rename / delete the

opera_autoupdate.exe

file which is located in folders like

C:\Users\YOUR-USER-NAME\AppData\Local\Programs\Opera\73.0.3856.329

and

C:\Users\YOUR-USER-NAME\AppData\Local\Programs\Opera\92.0.4561.21

which are created accordingly to the offline version of installment


A script like this does not work

Code: Select all

rename C:\Users\YOUR-USER-NAME\AppData\Local\Programs\Opera\*\opera_autoupdate.exe "opera_autoupdate   DISABLED.exe"

Thus: does anyone have an idea how to rework it? Or known of a similarly quick workaround [as going to Task Scheduler to disable its update tasks after every update would be to much of a drag]?

Re: How to [automatically] rename a file within a non-specified subfolder? [AKA stopping Opera from autoupdating]

Posted: 24 Oct 2022 20:06
by GeoffVass
On my system Opera is in Program Files so I wrote this to start at the root:

Code: Select all

forfiles /p c:\ /m opera_autoupdate.exe /s /c "cmd /c ren @path *.old" 2>nul
Otherwise could be:

Code: Select all

forfiles /p "%LocalAppData%" /m opera_autoupdate.exe /s /c "cmd /c ren @path *.old" 2>nul

Re: How to [automatically] rename a file within a non-specified subfolder? [AKA stopping Opera from autoupdating]

Posted: 03 Jan 2023 13:46
by DOSadnie
OK, so to educate myself I read what forfiles /? and ren /? spat out and:

#1] I could not find a reference to 2>nul - what does it do / where does it come from?

#2] If I prefer to keep that EXE in a more visible form, for whatever future purpose I might need it and as I surely in time will eventually forget about its existence, am I thus force to use something like this

Code: Select all

forfiles /p "%LocalAppData%" /m opera_autoupdate.exe /s /c "cmd /c ren @path *.exe___DISABLED" 2>nul
because

Code: Select all

forfiles /p "%LocalAppData%" /m opera_autoupdate.exe /s /c "cmd /c ren @path "*   DISABLED.*"" 2>nul
does not work [i.e. it is unable to rename it to >>opera_autoupdate   DISABLED.exe<<] nor will work anything similar to it [because of CMD limitations?

#3] How to upgrade such script with automatic overwriting of the renamed EXE? When Opera on my demand will upgrade once more then it will once again create brand new >>opera_autoupdate.exe<< file that will be in desperate need of being pacified - but because of the existence of the renamed old version of this EXE the current code will just leave it alone [thus inadvertently bringing back allowance for occurrences of automatic updates]

Re: How to [automatically] rename a file within a non-specified subfolder? [AKA stopping Opera from autoupdating]

Posted: 03 Jan 2023 15:03
by atfon
DOSadnie wrote:
03 Jan 2023 13:46
OK, so to educate myself I read what forfiles /? and ren /? spat out and:

#1] I could not find a reference to 2>nul - what does it do / where does it come from?
For this question, I would suggest reading up on Redirection: https://ss64.com/nt/syntax-redirection.html

This is to hide STDERR (error messages):
command 2> nul Redirect error messages to NUL

Re: How to [automatically] rename a file within a non-specified subfolder? [AKA stopping Opera from autoupdating]

Posted: 16 Jan 2023 10:08
by DOSadnie
atfon wrote:
03 Jan 2023 15:03
[...]
For this question, I would suggest reading up on Redirection: https://ss64.com/nt/syntax-redirection.html
[...]
Interesting site. Just by glancing through its content I just found me self a bran new favorite / optimal monospace font: Courier Prime Sans [https://ss64.com/fonts.html]

Re: How to [automatically] rename a file within a non-specified subfolder? [AKA stopping Opera from autoupdating]

Posted: 16 Jan 2023 10:09
by DOSadnie
Still: my problems #2 and #3 from initial post remain unsolved - can anyone help me with them?

Re: How to [automatically] rename a file within a non-specified subfolder? [AKA stopping Opera from autoupdating]

Posted: 17 Jan 2023 05:55
by Lucky4Me
Try the next code

Code: Select all

@for /F "tokens=1,2,3,4 delims=/ " %%A in ('Date /t') do @(
set Month=%%B
set Day=%%C
set Year=%%D
set now=%%B%%C%%D
)
for /f %%i in ( 'dir "%LocalAppData%\Programs\Opera\" /B /AD ^|findstr /r [0-9]' ) do (
if exist "%LocalAppData%\Programs\Opera\%%i\opera_autoupdate.exe" ren "%LocalAppData%\Programs\Opera\%%i\opera_autoupdate.exe" "opera_autoupdate%now%.exe"
)
it should detect the maps with a numeric value and check them for opera_autoupdate.exe and if opera_autoupdate.exe exist it will be renamed to opera_autoupdateMonthDayYear.exe