Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for uniqueid.bat

(view source code of uniqueid.bat as plain text)

  1. @ECHO OFF
  2. :: No command line parameters required
  3. IF NOT "%1"=="" GOTO Syntax
  4.  
  5. :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: ::
  6. :: Adjust the LANDesk server name and the drive and directory if necessary ::
  7. :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: ::
  8. SET LANDeskServer=MyLDServer
  9. C:
  10. CD\LDClient
  11.  
  12. ECHO Removing old LANDesk agent ID
  13.  
  14. :: Delete old ID file (adjust drive if necessary)
  15. IF EXIST C:\LDIScan.cfg ATTRIB -h -r -s C:\LDIScan.cfg
  16. IF EXIST C:\LDIScan.cfg DEL C:\LDIScan.cfg
  17.  
  18. :: Delete old ID from the registry (Local Machine)
  19. :: Create a temporary REG file
  20. > %TEMP%.\UniqueID.reg ECHO REGEDIT4
  21. >>%TEMP%.\UniqueID.reg ECHO.
  22. >>%TEMP%.\UniqueID.reg ECHO [HKEY_LOCAL_MACHINE\SOFTWARE\Intel\LANDesk\Common Api]
  23. >>%TEMP%.\UniqueID.reg ECHO "UniqueID"=-
  24. >>%TEMP%.\UniqueID.reg ECHO.
  25.  
  26. :: Check if previous ID was stored for Current User and if so, delete it
  27. IF EXIST %TEMP%.\_Unique_.REG DEL %TEMP%.\_Unique_.REG
  28. REGEDIT /E %TEMP%.\_Unique_.REG "HKEY_CURRENT_USER\SOFTWARE\Intel\LANDesk\LDWM\LDIScan32"
  29. TYPE %TEMP%.\_Unique_.REG | FIND /I "Last Device ID" >NUL 2>&1
  30. IF ERRORLEVEL 1 GOTO Next
  31. >>%TEMP%.\UniqueID.reg ECHO [HKEY_CURRENT_USER\SOFTWARE\Intel\LANDesk\LDWM\LDIScan32]
  32. >>%TEMP%.\UniqueID.reg ECHO "Last Device ID"=-
  33. >>%TEMP%.\UniqueID.reg ECHO.
  34.  
  35. :: Repeat for Default User
  36. :Next
  37. IF EXIST %TEMP%.\_Unique_.REG DEL %TEMP%.\_Unique_.REG
  38. REGEDIT /E %TEMP%.\_Unique_.REG "HKEY_USERS\.Default\SOFTWARE\Intel\LANDesk\LDWM\LDIScan32"
  39. TYPE %TEMP%.\_Unique_.REG | FIND /I "Last Device ID" >NUL 2>&1
  40. IF ERRORLEVEL 1 GOTO Merge
  41. DEL %TEMP%.\_Unique_.REG
  42. >>%TEMP%.\UniqueID.reg ECHO [HKEY_USERS\.Default\SOFTWARE\Intel\LANDesk\LDWM\LDIScan32]
  43. >>%TEMP%.\UniqueID.reg ECHO "Last Device ID"=-
  44. >>%TEMP%.\UniqueID.reg ECHO.
  45.  
  46. :: Merge (import) the REG file to delete the UniqueID entry
  47. :Merge
  48. REGEDIT /S %TEMP%.\UniqueID.reg
  49. :: Delete the temporary REG file
  50. DEL %TEMP%.\UniqueID.reg
  51.  
  52. ECHO Creating new LANDesk agent ID
  53.  
  54. :: Start inventory scan to create new ID
  55. LDISCN32.EXE /NTT=%LANDeskServer%:5007 /S="%LANDeskServer%" /I=\\%LANDeskServer%\LDLOGON\ldappl.ini /V
  56.  
  57. ECHO Done
  58. IF EXIST %TEMP%.\_Unique_.REG DEL %TEMP%.\_Unique_.REG
  59. SET LANDeskServer=
  60. CD\
  61. GOTO End
  62.  
  63. :Syntax
  64. ECHO UniqueID.bat,  Version 2.00 for 32-bit Windows
  65. ECHO Create a new unique ID for Intel LANDesk agent
  66. ECHO.
  67. ECHO If a computer is installed using a harddisk image (like Norton Ghost
  68. ECHO or PowerQuest's Drive Image) all "clones" will have the same LANDesk
  69. ECHO agent ID if LANDesk agent was installed when the image was created.
  70. ECHO However, the LANDesk agent needs a unique ID to function properly.
  71. ECHO You can force a new ID by reinstalling the LANDesk agent software,
  72. ECHO but running this batch file can force a new unique ID just as well.
  73. ECHO.
  74. ECHO Written by Rob van der Woude
  75. ECHO http://www.robvanderwoude.com
  76.  
  77. :End
  78.  

page last modified: 2024-04-16; loaded in 0.0085 seconds