Registry Values not Deleting

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
kpassaur
Automation Wizard
Posts: 696
Joined: Wed Jul 07, 2004 1:55 pm

Registry Values not Deleting

Post by kpassaur » Mon Apr 10, 2017 4:11 pm

I have used the code below for years with no issues and now it does not work. I am using a Windows 10 machine and I am logged in as an administrator. I have tried various things such as using the whole path with WOW6432NODE in it etc. It always reads it, it just doesn't delete it. Any ideas? Oh, yes I have tried with Windows Defender on and off.



// COMPILE_OPTS|C:\Users\Keith Passaur\Desktop\Reset Tiff to Text III.exe|C:\Users\Keith Passaur\Documents\Icons\allsizes2.ico|CONSOLE=0|INCLUDES=1| /LOGFILE=\dev\nul /HIDE /NOSTOPKEY|RUNTIMES=1|BMPS=1
RegistryReadKey>HKEY_LOCAL_MACHINE,SOFTWARE\eDocfile\Tiff to Text III,AppFolder,ProgramFolder
Let>APP_TITLE=Reset Tiff to Text III
//Let>REG_64=0

RegistryReadKey>HKEY_LOCAL_MACHINE,SOFTWARE\eDocFile\Tiff to Text III,itime,installedtime
RegistryDelVal>HKEY_LOCAL_MACHINE,SOFTWARE\eDocFile\Tiff to Text III,itime
RegistryDelKey>HKEY_LOCAL_MACHINE,SOFTWARE\eDocFile\Tiff to Text III,itime
RegistryReadKey>HKEY_LOCAL_MACHINE,SOFTWARE\eDocFile\Tiff to Text III,itime,installedtime

If>installedtime=
MDL>Tiff to Text III has been reset
Else
MDL>The program is still running in Trial mode
Endif

//HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\eDocfile\Tiff to Text III

User avatar
CyberCitizen
Automation Wizard
Posts: 721
Joined: Sun Jun 20, 2004 7:06 am
Location: Adelaide, South Australia

Re: Registry Values not Deleting

Post by CyberCitizen » Thu May 04, 2017 12:39 pm

Naughty Naughty Exploiting Trials :P
FIREFIGHTER

kpassaur
Automation Wizard
Posts: 696
Joined: Wed Jul 07, 2004 1:55 pm

Re: Registry Values not Deleting

Post by kpassaur » Thu May 04, 2017 1:11 pm

That is not the case. It extends a trial of software that I sell. Since this code has stopped working and I have gotten no response I have had to rewrite the software so the settings are no longer stored in the registry. This is a bug in Macro Scheduler as the code above has worked for years. I'm sure it has to do with Windows security.

User avatar
Marcus Tettmar
Site Admin
Posts: 7378
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: Registry Values not Deleting

Post by Marcus Tettmar » Wed May 10, 2017 9:21 am

To write to HKEY_LOCAL_MACHINE (or create/delete) a process (ANY process) will require Admin privileges. This has ALWAYS been the case but not usually enforced until Windows Vista came along.

An ordinary process ca READ frlm HKLM but would need admin rights to modify.

The correct placed for an ordinary user level process to store settings is HKEY_CURRENT_USER which you CAN modify without being Admin.

There are some good reasons for storing data in HKEY_LOCAL_MACHINE when your app is being installed. Which is why installers nearly always run as admin (admin rights are also need to write files to the Program Files location).

All the above is as designed by Microsoft. Therefore it is absolutely NOT a Macro Scheduler bug as you state.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

kpassaur
Automation Wizard
Posts: 696
Joined: Wed Jul 07, 2004 1:55 pm

Re: Registry Values not Deleting

Post by kpassaur » Wed May 10, 2017 11:30 am

I understand having to be logged in as an admin and I am. I have used those lines for over 10 years all the way back to XP without any issues. They worked on Windows 10 until about a month or so ago. I'm sure it is because of a security setting in Windows, but at the end of the day when logged in with the administrator account they don't work any more.

That being said, yes I can still read the entries but I can't modify them. I can however export a reg entry, modify it, save it on my desktop and execute it and it will work. I don't think this would work if I was logged in as anything other than an administrator.

Anyway, if I am logged in as an administrator, with Windows defender turned off how do I correct this so that it does work.

User avatar
Marcus Tettmar
Site Admin
Posts: 7378
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: Registry Values not Deleting

Post by Marcus Tettmar » Wed May 10, 2017 4:07 pm

Being logged in as an admin is not enough, Macro Scheduler, or the .exe, will also have to be run as Admin. Even though you might be logged in as administrator, that doesn't necessarily mean that processes you start will be started with admin privileges.

Right click on Macro Scheduler and select run as admin.

I tested this code on Windows 10:

Code: Select all

RegistryWriteKey>HKEY_LOCAL_MACHINE,SOFTWARE\eDocFile\Tiff to Text III,itime,hello
RegistryReadKey>HKEY_LOCAL_MACHINE,SOFTWARE\eDocFile\Tiff to Text III,itime,installedtime
RegistryDelVal>HKEY_LOCAL_MACHINE,SOFTWARE\eDocFile\Tiff to Text III,itime
RegistryDelKey>HKEY_LOCAL_MACHINE,SOFTWARE\eDocFile\Tiff to Text III,itime
RegistryReadKey>HKEY_LOCAL_MACHINE,SOFTWARE\eDocFile\Tiff to Text III,itime,installedtime
Without running as admin the key never gets created. If I run as admin everything works - it gets created, and then deleted.

With this code on it's own if you are on 64 bit you need to look in Wow6432Node to verify.

If I add this to the top:

Let>REG_64=1

Then it operates against the regular HKEY_LOCAL_MACHINE node.

Stepping through line by line and hitting refresh (F5) while in RegEdit allows me to see that it all works correctly.

BUT - ONLY IF Macro Scheduler is run as admin.

I'm logged in as an administrator. But it will NOT work unless Macro Scheduler is run as administrator. Since Vista EVEN IF you are the administrator apps are run by default with ordinary level privileges.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

kpassaur
Automation Wizard
Posts: 696
Joined: Wed Jul 07, 2004 1:55 pm

Re: Registry Values not Deleting

Post by kpassaur » Wed May 10, 2017 4:20 pm

I have always run it compiled, so I guess now even though I am logged in as an administrator I have to right click it and select run as an administrator as well.

Or perhaps I could try compiling using the real administrator account instead of being logged in as an administrator.

User avatar
Marcus Tettmar
Site Admin
Posts: 7378
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: Registry Values not Deleting

Post by Marcus Tettmar » Wed May 10, 2017 4:25 pm

However you compile it you will need to specifically choose to run it as admin. Unless you completely disable UAC (making Windows insecure). You could set a shortcut to it that tells it to run as admin but then you would still need to confirm the UAC prompt (unless you've disabled UAC).

This really is not new and has been the case since Vista. Only in XP and below did apps adopt the user's privilege level.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

kpassaur
Automation Wizard
Posts: 696
Joined: Wed Jul 07, 2004 1:55 pm

Re: Registry Values not Deleting

Post by kpassaur » Wed May 10, 2017 5:28 pm

I have never had the issue until now. However, I am beginning to think it is may machine. I couldn't get your sample to work stepping through it. I tried it with a real administrator account which has UAC completely disabled and it didn't work.

So I went to reboot and start over and it locked up on "please wait windows is installing updates do not turn off your computer".

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts