User Tools

Site Tools


userspace:windows_remove_temporary_profile

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
userspace:windows_remove_temporary_profile [2017/04/03 09:29]
bobzbobz
userspace:windows_remove_temporary_profile [2021/08/23 08:37] (current)
Line 1: Line 1:
 ====== Windows Remove Temporary Profiles ====== ====== Windows Remove Temporary Profiles ======
-//Scripts and Guide by Soren Birk.//+//Scripts and guide by Soren Birk.//
  
-This scripts checks for temporary profiles in the registry and deletes them, if found.+This scripts checks for temporary profiles in the registry and deletes them, if any found.
  
 **Tested with:** **Tested with:**
Line 12: Line 12:
 <code> <code>
 CLIENT_DATA CLIENT_DATA
-  ├ registry.png+  ├ registrylogo.png
   └ once.ins   └ once.ins
 +</code>
 +
 +==== once.ins ====
 +<code winst>
 +; Author Soren Birk
 +
 +[Actions]
 +requiredWinstVersion >= "4.11.2.6"
 +
 +DefVar $ProductId$
 +DefVar $UserProfileName$
 +DefVar $SID$
 +DefStringList $SIDcmd$
 +DefStringList $UserProfileNamesList$
 +
 +set $UserProfileNamesList$ = getOutStreamFromSection ('DosInAnIcon_list_profiledir')
 +
 +; ----------------------------------------------------------------
 +; - Please edit these values                                     -
 +; ----------------------------------------------------------------
 +Set $ProductId$       = "remove-temp-profiles"
 +; ----------------------------------------------------------------
 +comment "Show product logo"
 +ShowBitmap "%ScriptPath%\registrylogo.png" "Remove temporary profiles"
 +
 +Message "Removing temporary profiles ..."
 +
 +comment "Removing .bak-files"
 +ChangeDirectory "%SCRIPTPATH%"
 +for %prof% in $UserProfileNamesList$ do sub_remove_bak
 +
 +
 +[DosInAnIcon_list_profiledir]
 +@echo off
 +dir "%ProfileDir%" /b /ad
 +
 +[sub_remove_bak]
 +Set $UserProfileName$ = "%prof%"
 +if not ($UserProfileName$ = "") and not ($UserProfileName$ = "All Users") and not ($UserProfileName$ = "Public") and not ($UserProfileName$ = "LocalService") and not ($UserProfileName$ = "NetworkService")
 + Set $SIDcmd$ = getOutStreamFromSection ('DosInAnIcon_getuser')
 + Set $SID$ = trim(takeFirstStringContaining($SIDcmd$,"S-"))
 +
 + comment "Removing .bak-file for " + $UserProfileName$ + " if it exists..."
 + Registry_install
 +endif
 +
 +[DosInAnIcon_getuser]
 +wmic useraccount where name='$UserProfileName$' get sid
 +
 +[Registry_install]
 +Deletekey [HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\$SID$.bak]
 +
 </code> </code>
userspace/windows_remove_temporary_profile.1491211758.txt.gz · Last modified: 2021/08/23 08:37 (external edit)