home *** CD-ROM | disk | FTP | other *** search
/ PC World 2007 March / PCWorld_2007-03_cd.bin / audio-video / fireant / FireAntSetup_RC1.msi / _5DD22B4F19113B30369E52193993D947 / _B53751AE8D1B47079F0B075033F226DC < prev    next >
Text File  |  2005-12-17  |  4KB  |  118 lines

  1.  
  2. Option Explicit
  3. 'having this on *all* the time is *always* a bad idea!!!
  4. On Error Resume Next
  5.  
  6. ' Registry key hives.
  7. Const HKEY_CLASSES_ROOT = &H80000000
  8. Const HKEY_CURRENT_USER = &H80000001
  9. Const HKEY_LOCAL_MACHINE = &H80000002
  10. Const HKEY_USERS = &H80000003
  11. Const HKEY_CURRENT_CONFIG = &H80000005
  12. Const HKEY_DYN_DATA = &H80000006
  13.  
  14. Private Const NOERROR = 0
  15. Private Const MAX_PATH = 260
  16.  
  17. ' CSIDL constants.
  18. Private Const CSIDL_DESKTOP = &H0
  19. Private Const CSIDL_INTERNET = &H1
  20. Private Const CSIDL_PROGRAMS = &H2
  21. Private Const CSIDL_CONTROLS = &H3
  22. Private Const CSIDL_PRINTERS = &H4
  23. Private Const CSIDL_PERSONAL = &H5
  24. Private Const CSIDL_FAVORITES = &H6
  25. Private Const CSIDL_STARTUP = &H7
  26. Private Const CSIDL_RECENT = &H8
  27. Private Const CSIDL_SENDTO = &H9
  28. Private Const CSIDL_BITBUCKET = &HA
  29. Private Const CSIDL_STARTMENU = &HB
  30. Private Const CSIDL_DESKTOPDIRECTORY = &H10
  31. Private Const CSIDL_DRIVES = &H11
  32. Private Const CSIDL_NETWORK = &H12
  33. Private Const CSIDL_NETHOOD = &H13
  34. Private Const CSIDL_FONTS = &H14
  35. Private Const CSIDL_TEMPLATES = &H15
  36. Private Const CSIDL_COMMON_STARTMENU = &H16
  37. Private Const CSIDL_COMMON_PROGRAMS = &H17
  38. Private Const CSIDL_COMMON_STARTUP = &H18
  39. Private Const CSIDL_COMMON_DESKTOPDIRECTORY = &H19
  40. Private Const CSIDL_APPDATA = &H1A
  41. Private Const CSIDL_LOCAL_APPDATA = &H1C
  42. Private Const CSIDL_PRINTHOOD = &H1B
  43. Private Const CSIDL_ALTSTARTUP = &H1D
  44. Private Const CSIDL_COMMON_ALTSTARTUP = &H1E
  45. Private Const CSIDL_COMMON_FAVORITES = &H1F
  46. Private Const CSIDL_INTERNET_CACHE = &H20
  47. Private Const CSIDL_COOKIES = &H21
  48. Private Const CSIDL_HISTORY = &H22
  49.  
  50. '********************************************************************************
  51.  
  52. CleanANTFolders
  53. CleanANTRegistry
  54.  
  55. 'wscript.echo "Done!"
  56. Sub CleanANTFolders
  57.     Dim appDataPath 
  58.     Dim oldAppDataPath
  59.     Dim newAppDataPath
  60.     Dim fso
  61.     
  62.     'wscript.echo "Creating FileSystemObject"
  63.     Set fso = CreateObject("Scripting.FileSystemObject")
  64.     
  65.     oldAppDataPath = GetSpecialFolderLocation(CSIDL_LOCAL_APPDATA) & "\FireAnt"
  66.     newAppDataPath = GetSpecialFolderLocation(CSIDL_LOCAL_APPDATA) & "\Mycelia Networks\FireAnt"
  67.     
  68.     fso.CreateFolder GetSpecialFolderLocation(CSIDL_LOCAL_APPDATA) & "\Mycelia Networks"
  69.     fso.CreateFolder newAppDataPath
  70.     fso.CopyFile oldAppDataPath & "\FireAnt.opml", newAppDataPath & "\FireAnt.opml"
  71.     
  72.     'wscript.echo "Deleting " & oldAppDataPath
  73.     fso.DeleteFile oldAppDataPath & "\FireAnt.fdb"
  74.     fso.DeleteFile oldAppDataPath & "\FireAnt.log"
  75.     fso.DeleteFolder oldAppDataPath, True
  76.             
  77.     appDataPath = GetSpecialFolderLocation(CSIDL_APPDATA) & "\FireAnt"
  78.     fso.DeleteFolder appDataPath, True    
  79. End Sub
  80.  
  81. Sub CleanANTRegistry
  82.     'Delete registry settings for ANT.
  83.     DeleteRegistryKey HKEY_CURRENT_USER, "Software\ANTisNOTTV"
  84. End Sub
  85.  
  86. ' Gets a Windows "special" folder location.
  87. Function GetSpecialFolderLocation(csidl)
  88.     Dim shellApp
  89.     Dim folderName
  90.     
  91.     Set shellApp = CreateObject("Shell.Application")
  92.     
  93.     folderName = shellApp.Namespace(csidl).Self.Path
  94.     GetSpecialFolderLocation = folderName
  95. End Function
  96.  
  97. '********************************************************************************
  98. ' Recursively delete registry keys.
  99. Sub DeleteRegistryKey(RegRoot, SPath)
  100.     Dim sKeys
  101.     Dim SubKeyCount
  102.     Dim objRegistry
  103.     Dim lRC
  104.     Dim lRC2
  105.     Dim Key
  106.     Set objRegistry = GetObject("winmgmts:root\default:StdRegProv")
  107.  
  108.     'wscript.echo "ENUMERATING KEY: " & sPath & "\" & Key
  109.     lRC = objRegistry.EnumKey(RegRoot, sPath, sKeys)
  110.  
  111.     If IsArray(sKeys) Then
  112.         For Each Key in sKeys
  113.             DeleteRegistryKey RegRoot, SPath & "\" & Key
  114.         Next
  115.     End If
  116.     lRC2 = objRegistry.DeleteKey(RegRoot, sPath)
  117. End Sub
  118.