CitrixConfig.cmd 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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\SnFileControl\Instances\SnFileControl Instance" /v Altitude /t REG_SZ /d 134120 /f
  31. call :CheckStatus "[ERROR] Failed to change Altitude for driver SnFileControl"
  32. rem ================================================================================
  33. rem Add parameter for device control
  34. reg add "HKLM\System\CurrentControlSet\Services\SnDDD\DC" /v AllowUnknownDisk /t REG_DWORD /d 1 /f
  35. call :CheckStatus "[ERROR] Failed to set parameter AllowUnknownDisk"
  36. rem ================================================================================
  37. rem Add parameter for database handling
  38. reg add "HKLM\SYSTEM\CurrentControlSet\Services\SnCC0" /v ClearDatabaseLogs /t REG_DWORD /d 1 /f
  39. call :CheckStatus "[ERROR] Failed to set parameter ClearDatabaseLogs"
  40. rem ================================================================================
  41. rem Configure Citrix PvD
  42. echo Writing to file %configpath%\custom_folders_rules.txt
  43. echo [Rule-Begin]>> %configpath%\custom_folders_rules.txt
  44. echo Type=File-Catalog-Construction>> %configpath%\custom_folders_rules.txt
  45. echo Action=Catalog-Location-Guest-Modifiable>> %configpath%\custom_folders_rules.txt
  46. echo name="%%PROGRAMFILES%%\Secret Net Studio\Client\Grouppolicy\*">> %configpath%\custom_folders_rules.txt
  47. echo name="%%PROGRAMFILES%%\Secret Net Studio\Client\Grouppolicy\**\*">> %configpath%\custom_folders_rules.txt
  48. echo name="%%PROGRAMFILES%%\Secret Net Studio\Client\icheck\**\*">> %configpath%\custom_folders_rules.txt
  49. echo [Rule-End]>> %configpath%\custom_folders_rules.txt
  50. echo.>> %configpath%\custom_folders_rules.txt
  51. echo [Rule-Begin]>> %configpath%\custom_folders_rules.txt
  52. echo Type=Inclusion-Exclusion>> %configpath%\custom_folders_rules.txt
  53. echo Action=Exclude-Diff>> %configpath%\custom_folders_rules.txt
  54. echo name="\System Volume Information\SnCloneVault\**\*">> %configpath%\custom_folders_rules.txt
  55. echo [Rule-End]>> %configpath%\custom_folders_rules.txt
  56. echo Writing to file %configpath%\custom_regkey_rules.txt
  57. echo [Rule-Begin]>> %configpath%\custom_regkey_rules.txt
  58. echo Type=Conflict-Resolution>> %configpath%\custom_regkey_rules.txt
  59. echo Action=use-fullsrc-backup-fulldst>> %configpath%\custom_regkey_rules.txt
  60. echo name="SECURITY\SNET\**\*">> %configpath%\custom_regkey_rules.txt
  61. echo name="SOFTWARE\infosec\**\*">> %configpath%\custom_regkey_rules.txt
  62. echo name="snddd\dc\**\*">> %configpath%\custom_regkey_rules.txt
  63. echo name="snfilecontrol\sectree\**\*">> %configpath%\custom_regkey_rules.txt
  64. echo [Rule-End]>> %configpath%\custom_regkey_rules.txt
  65. rem ================================================================================
  66. if "%log_dir%" neq "" (
  67. echo Configuration done > "%log_dir%success.%computername%.%userdomain%.citrix_config.log"
  68. ) else (
  69. color 0A
  70. echo Configuration done
  71. pause
  72. )
  73. exit /b
  74. rem ================================================================================
  75. :CheckStatus
  76. if %errorlevel% neq 0 (
  77. if "%log_dir%" neq "" (
  78. echo %~1 > "%log_dir%fail.%computername%.%userdomain%.citrix_config.log"
  79. ) else (
  80. color 0C
  81. echo.
  82. echo %~1
  83. echo.
  84. pause
  85. )
  86. exit
  87. )
  88. exit /b
  89. rem ================================================================================
  90. rem Run script elevated (UAC)
  91. :Elevate
  92. set "vbsGetPrivileges=%temp%\SNgetPriv_%~n0.vbs"
  93. echo.
  94. echo **************************************
  95. echo Running as administrator
  96. echo **************************************
  97. echo Set UAC = CreateObject^("Shell.Application"^) > "%vbsGetPrivileges%"
  98. echo args = "ELEV " >> "%vbsGetPrivileges%"
  99. echo For Each strArg in WScript.Arguments >> "%vbsGetPrivileges%"
  100. echo args = args ^& strArg ^& " " >> "%vbsGetPrivileges%"
  101. echo Next >> "%vbsGetPrivileges%"
  102. echo args = "/c """ + "%~f0" + """ " + args >> "%vbsGetPrivileges%"
  103. echo UAC.ShellExecute "%SystemRoot%\system32\cmd.exe", args, "", "runas", 1 >> "%vbsGetPrivileges%"
  104. rem echo UAC.ShellExecute "%~f0", args, "", "runas", 1 >> "%vbsGetPrivileges%"
  105. "%SystemRoot%\system32\WScript.exe" "%vbsGetPrivileges%" %*
  106. exit /b