Reset Out Profile by delete outlook folder and one registry

Need help with the actionscript below:

// Disable wow64 redirection on x64 OSes
//action uses wow64 redirection {not x64 of operating system}
waithidden cmd /C taskkill { ("/pid " & it) of concatenations "/pid " of (it as string) of pids of processes "OUTLOOK.EXE" } /T /F
waithidden cmd /C taskkill { ("/pid " & it) of concatenations "/pid " of (it as string) of pids of processes "lync.exe" } /T /F
waithidden cmd /C taskkill { ("/pid " & it) of concatenations "/pid " of (it as string) of pids of processes "SkypeHost.exe" } /T /F
waithidden cmd /C taskkill { ("/pid " & it) of concatenations "/pid " of (it as string) of pids of processes "Teams.exe" } /T /F
waithidden cmd /C taskkill { ("/pid " & it) of concatenations "/pid " of (it as string) of pids of processes "OneDrive.exe" } /T /F

dos reg.exe delete HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Outlook\Profiles\Outlook /f
dos reg.exe add HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Outlook\Profiles\Outlook

folder delete "C:\Users\{name of logged on user}\AppData\Local\Microsoft\Outlook"

In above script everything works except for the part where I’m trying to delete registry key and create one.

Need assistance. The script complete but no changes are made to registry.

This is the part where I need help:

dos reg.exe delete HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Outlook\Profiles\Outlook /f
dos reg.exe add HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Outlook\Profiles\Outlook

This is what I tried so far with status:

dos reg.exe delete HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Outlook\Profiles\Outlook /f
dos reg.exe add HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Outlook\Profiles\Outlook

Status: Completed but no change was made to registry.

waithidden reg.exe delete HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Outlook\Profiles\Outlook /f
waithidden reg.exe add HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Outlook\Profiles\Outlook

Status: Complete with no change.

//**Begin Preparation Marker
// Download all specified files
begin prefetch block
  add prefetch item name=F5A4A8E27B428C2D9A1C1BA7D72BA08B77406A9C sha1=f5a4a8e27b428c2d9a1c1ba7d72ba08b77406a9c size=380208 url=SWDProtocol://127.0.0.1:52311/Uploads/F5A4A8E27B428C2D9A1C1BA7D72BA08B77406A9C/LGPO.exe.bfswd sha256=a8e0b52dea3836071f3f46235c126cb7fe986abdcc3d1b819d7c2cd101999cb3
end prefetch block

// All SWD files will go into a folder in the clients __BESData folder. This folder gets cleared on every restart.
parameter "baseFolder" =  "__Download/"
// Move files into subfolders and unescape file names
move "__Download/F5A4A8E27B428C2D9A1C1BA7D72BA08B77406A9C" "{parameter "baseFolder"}LGPO.exe" 

// Log setup
parameter "mainSWDLogFolder" = "{parent folder of client folder of current site}/__Global/SWDDeployData"
folder create "{parameter "mainSWDLogFolder"}"
parameter "logFile" = "SWD_DeploymentResults.log"

//**End Preparation Marker
// Create LGPO file to be applied to the system
delete __createfile
delete __Download\LGPOtoApply.txt
createfile until EOF

User
Software\Microsoft\Office\16.0\Outlook\Profiles
Outlook
DELETEKEYS

EOF

move __createfile "{pathname of client folder of current site}\__Download\LGPOtoApply.txt"

waithidden "{pathname of client folder of current site}\__Download\LGPO.exe" /t __Download\LGPOtoApply.txt

override wait
hidden=true
runas=currentuser
wait CMD /C echo n | gpupdate /target:user /wait:60

// Task will now exit.
exit {parameter "returnCode"}
//**End Closing Marker

Status: Failed

delete __createfile
delete __Download\LGPOtoApply.bat
createfile until EOF

reg.exe delete HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Outlook\Profiles\Outlook /f
reg.exe add HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Outlook\Profiles\Outlook

EOF

move __createfile "{pathname of client folder of current site}\__Download\LGPOtoApply.bat"

override wait
hidden=true
runas=currentuser
wait CMD /C LGPOtoApply.bat

Status: Completed with no change.

dos reg delete "HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Outlook\Profiles\Outlook" /f

Status: Completed with no change

regdelete64 "[HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Outlook\Profiles\Outlook]"

Status: Failed

regdelete64 "[HKCU\Software\Microsoft\Office\16.0\Outlook\Profiles\Outlook]"

Status: Failed

regdelete "[HKCU\Software\Microsoft\Office\16.0\Outlook\Profiles\Outlook]"

regdelete64 "[HKCU\Software\Microsoft\Office\16.0\Outlook\Profiles\Outlook]"

Status: Failed

regdelete "[HKCU\Software\Microsoft\Office\16.0\Outlook\Profiles\outlook]" "outlook"

regdelete64 "[HKCU\Software\Microsoft\Office\16.0\Outlook\Profiles\outlook]" "outlook"

Status: Failed

action uses wow64 redirection false

waithidden reg.exe delete "HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Outlook\Profiles\outlook" /f

Status: Failed

action uses wow64 redirection false

waithidden reg.exe delete "HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Outlook\Profiles" /v "Outlook" /f

Status: Failed

regkeydelete64 "[HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Outlook\Profiles\Outlook]"

Status: Failed

regdelete "[HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Outlook\Profiles" "Outlook"

Status: Completed with no change.

Try “action uses wow64 redirection false” before the dos command:

action uses wow64 redirection false
dos reg delete “HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Outlook\Profiles\Outlook” /f

In general, the Bigfix “regdelete” command is used to delete the “key” and the sintax is:
regdelete “” “”

Tried, completed by no change in registry.

I am trying to delete the key here. That last one outlook is the key that I need deleted.

HKCU is a virtual hive, only mounted for the logged-on user. And each logged-on user gets a different one.

There are options to use ‘override wait’ or substitutions for ‘user keys of logged on users’ but I can’t type it out on my phone right now

Thanks Jason, can you send those when you get a chance please?

I figured it out with your idea.

So I created .bat file with these two lines:

reg.exe delete HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Outlook\Profiles\Outlook /f
reg.exe add HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Outlook\Profiles\Outlook

Uploaded to software distribution and ran as current user and it worked.

Thank you all for input.

Glad you got it working.

It might be easier to just use createfile within the task instead of deploying a batch file to run it.

Great idea, I will try that for sure.