CitrixConfig.cmd 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. @echo off
  2. rem Version 02.11.2017
  3. rem ================================================================================
  4. rem Check for admin rights
  5. if '%1'=='ELEV' (shift /1 & goto Install)
  6. >nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
  7. if %errorlevel% neq 0 (
  8. goto Elevate
  9. )
  10. :Install
  11. rem ================================================================================
  12. rem If specified, parameter must contain path to log directory
  13. set log_dir=%~1
  14. if ^"%log_dir%^" neq "" (
  15. set fin=%log_dir:~-1%
  16. if "%fin%" neq "\" (set log_dir=%log_dir%\)
  17. )
  18. rem ================================================================================
  19. rem Obtaining necessary paths
  20. rem You can set Citrix PvD config path if it does not match default
  21. set configpath="%ProgramData%\Citrix\personal vDisk\Config"
  22. >nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" %configpath%
  23. call :CheckStatus "[ERROR] Invalid Citrix PvD config path"
  24. rem ================================================================================
  25. rem Change Altitude
  26. reg add "HKLM\System\CurrentControlSet\Services\SnCloneVault\Instances\SnCloneVault Instance" /v Altitude /t REG_SZ /d 134100 /f
  27. call :CheckStatus "[ERROR] Failed to change Altitude for driver SnCloneVault"
  28. reg add "HKLM\System\CurrentControlSet\Services\SnEraser\Instances\SnEraser Instance" /v Altitude /t REG_SZ /d 134110 /f
  29. call :CheckStatus "[ERROR] Failed to change Altitude for driver SnEraser"
  30. reg add "HKLM\System\CurrentControlSet\Services\SnSdd\Instances\SnSdd Instance" /v Altitude /t REG_SZ /d 134119 /f
  31. call :CheckStatus "[ERROR] Failed to change Altitude for driver SnSdd"
  32. reg add "HKLM\System\CurrentControlSet\Services\SnFileControl\Instances\SnFileControl Instance" /v Altitude /t REG_SZ /d 134120 /f
  33. call :CheckStatus "[ERROR] Failed to change Altitude for driver SnFileControl"
  34. rem ================================================================================
  35. rem Add parameter for device control
  36. reg add "HKLM\System\CurrentControlSet\Services\SnDDD\DC" /v AllowUnknownDisk /t REG_DWORD /d 1 /f
  37. call :CheckStatus "[ERROR] Failed to set parameter AllowUnknownDisk"
  38. rem ================================================================================
  39. rem Add parameter for database handling
  40. reg add "HKLM\SYSTEM\CurrentControlSet\Services\SnCC0" /v ClearDatabaseLogs /t REG_DWORD /d 1 /f
  41. call :CheckStatus "[ERROR] Failed to set parameter ClearDatabaseLogs"
  42. rem ================================================================================
  43. rem Configure Citrix PvD
  44. echo Writing to file %configpath%\custom_folders_rules.txt
  45. echo [Rule-Begin]>> %configpath%\custom_folders_rules.txt
  46. echo Type=File-Catalog-Construction>> %configpath%\custom_folders_rules.txt
  47. echo Action=Catalog-Location-Guest-Modifiable>> %configpath%\custom_folders_rules.txt
  48. echo name="%%PROGRAMFILES%%\Secret Net Studio\Client\Grouppolicy\*">> %configpath%\custom_folders_rules.txt
  49. echo name="%%PROGRAMFILES%%\Secret Net Studio\Client\Grouppolicy\**\*">> %configpath%\custom_folders_rules.txt
  50. echo name="%%PROGRAMFILES%%\Secret Net Studio\Client\icheck\**\*">> %configpath%\custom_folders_rules.txt
  51. echo [Rule-End]>> %configpath%\custom_folders_rules.txt
  52. echo.>> %configpath%\custom_folders_rules.txt
  53. echo [Rule-Begin]>> %configpath%\custom_folders_rules.txt
  54. echo Type=Inclusion-Exclusion>> %configpath%\custom_folders_rules.txt
  55. echo Action=Exclude-Diff>> %configpath%\custom_folders_rules.txt
  56. echo name="\System Volume Information\SnCloneVault\**\*">> %configpath%\custom_folders_rules.txt
  57. echo [Rule-End]>> %configpath%\custom_folders_rules.txt
  58. echo Writing to file %configpath%\custom_regkey_rules.txt
  59. echo [Rule-Begin]>> %configpath%\custom_regkey_rules.txt
  60. echo Type=Conflict-Resolution>> %configpath%\custom_regkey_rules.txt
  61. echo Action=use-fullsrc-backup-fulldst>> %configpath%\custom_regkey_rules.txt
  62. echo name="SECURITY\SNET\**\*">> %configpath%\custom_regkey_rules.txt
  63. echo name="SOFTWARE\infosec\**\*">> %configpath%\custom_regkey_rules.txt
  64. echo name="snddd\dc\**\*">> %configpath%\custom_regkey_rules.txt
  65. echo name="snfilecontrol\sectree\**\*">> %configpath%\custom_regkey_rules.txt
  66. echo [Rule-End]>> %configpath%\custom_regkey_rules.txt
  67. rem ================================================================================
  68. if "%log_dir%" neq "" (
  69. echo Configuration done > "%log_dir%success.%computername%.%userdomain%.citrix_config.log"
  70. ) else (
  71. color 0A
  72. echo Configuration done
  73. pause
  74. )
  75. exit /b
  76. rem ================================================================================
  77. :CheckStatus
  78. if %errorlevel% neq 0 (
  79. if "%log_dir%" neq "" (
  80. echo %~1 > "%log_dir%fail.%computername%.%userdomain%.citrix_config.log"
  81. ) else (
  82. color 0C
  83. echo.
  84. echo %~1
  85. echo.
  86. pause
  87. )
  88. exit
  89. )
  90. exit /b
  91. rem ================================================================================
  92. rem Run script elevated (UAC)
  93. :Elevate
  94. set "vbsGetPrivileges=%temp%\SNgetPriv_%~n0.vbs"
  95. echo.
  96. echo **************************************
  97. echo Running as administrator
  98. echo **************************************
  99. echo Set UAC = CreateObject^("Shell.Application"^) > "%vbsGetPrivileges%"
  100. echo args = "ELEV " >> "%vbsGetPrivileges%"
  101. echo For Each strArg in WScript.Arguments >> "%vbsGetPrivileges%"
  102. echo args = args ^& strArg ^& " " >> "%vbsGetPrivileges%"
  103. echo Next >> "%vbsGetPrivileges%"
  104. echo args = "/c """ + "%~f0" + """ " + args >> "%vbsGetPrivileges%"
  105. echo UAC.ShellExecute "%SystemRoot%\system32\cmd.exe", args, "", "runas", 1 >> "%vbsGetPrivileges%"
  106. rem echo UAC.ShellExecute "%~f0", args, "", "runas", 1 >> "%vbsGetPrivileges%"
  107. "%SystemRoot%\system32\WScript.exe" "%vbsGetPrivileges%" %*
  108. exit /b