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

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
DOSadnie
Posts: 143
Joined: 21 Jul 2022 15:12
Location: Coding Kindergarten

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

#1 Post by DOSadnie » 24 Oct 2022 14:00

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]?

GeoffVass
Posts: 10
Joined: 04 Oct 2021 17:34

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

#2 Post by GeoffVass » 24 Oct 2022 20:06

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

DOSadnie
Posts: 143
Joined: 21 Jul 2022 15:12
Location: Coding Kindergarten

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

#3 Post by DOSadnie » 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?

#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]
Last edited by DOSadnie on 04 Jan 2023 08:38, edited 1 time in total.

atfon
Posts: 178
Joined: 06 Oct 2017 07:33

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

#4 Post by atfon » 03 Jan 2023 15:03

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

DOSadnie
Posts: 143
Joined: 21 Jul 2022 15:12
Location: Coding Kindergarten

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

#5 Post by DOSadnie » 16 Jan 2023 10:08

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]

DOSadnie
Posts: 143
Joined: 21 Jul 2022 15:12
Location: Coding Kindergarten

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

#6 Post by DOSadnie » 16 Jan 2023 10:09

Still: my problems #2 and #3 from initial post remain unsolved - can anyone help me with them?

Lucky4Me
Posts: 19
Joined: 21 Oct 2020 06:33

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

#7 Post by Lucky4Me » 17 Jan 2023 05:55

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

Post Reply