Advertisement
Guest User

Custom redshift installer & setup, tested on windows 10 x64

a guest
Sep 2nd, 2022
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 3.14 KB | None | 0 0
  1. ::::::::::::::::::::::::::::::::::::::::::::
  2. :: Elevate.cmd - Version 4
  3. :: Automatically check & get admin rights
  4. :: see "https://stackoverflow.com/a/12264592/1016343" for description
  5. ::::::::::::::::::::::::::::::::::::::::::::
  6.  @echo off
  7.  CLS
  8.  ECHO.
  9.  ECHO =============================
  10.  ECHO Running Admin shell
  11.  ECHO =============================
  12.  
  13. :init
  14.  setlocal DisableDelayedExpansion
  15.  set cmdInvoke=1
  16.  set winSysFolder=System32
  17.  set "batchPath=%~0"
  18.  for %%k in (%0) do set batchName=%%~nk
  19.  set "vbsGetPrivileges=%temp%\OEgetPriv_%batchName%.vbs"
  20.  setlocal EnableDelayedExpansion
  21.  
  22. :checkPrivileges
  23.   NET FILE 1>NUL 2>NUL
  24.   if '%errorlevel%' == '0' ( goto gotPrivileges ) else ( goto getPrivileges )
  25.  
  26. :getPrivileges
  27.   if '%1'=='ELEV' (echo ELEV & shift /1 & goto gotPrivileges)
  28.   ECHO.
  29.   ECHO **************************************
  30.   ECHO Invoking UAC for Privilege Escalation
  31.   ECHO **************************************
  32.  
  33.   ECHO Set UAC = CreateObject^("Shell.Application"^) > "%vbsGetPrivileges%"
  34.   ECHO args = "ELEV " >> "%vbsGetPrivileges%"
  35.   ECHO For Each strArg in WScript.Arguments >> "%vbsGetPrivileges%"
  36.   ECHO args = args ^& strArg ^& " "  >> "%vbsGetPrivileges%"
  37.   ECHO Next >> "%vbsGetPrivileges%"
  38.  
  39.   if '%cmdInvoke%'=='1' goto InvokeCmd
  40.  
  41.   ECHO UAC.ShellExecute "!batchPath!", args, "", "runas", 1 >> "%vbsGetPrivileges%"
  42.   goto ExecElevation
  43.  
  44. :InvokeCmd
  45.   ECHO args = "/c """ + "!batchPath!" + """ " + args >> "%vbsGetPrivileges%"
  46.   ECHO UAC.ShellExecute "%SystemRoot%\%winSysFolder%\cmd.exe", args, "", "runas", 1 >> "%vbsGetPrivileges%"
  47.  
  48. :ExecElevation
  49.  "%SystemRoot%\%winSysFolder%\WScript.exe" "%vbsGetPrivileges%" %*
  50.  exit /B
  51.  
  52. :gotPrivileges
  53.  setlocal & cd /d %~dp0
  54.  if '%1'=='ELEV' (del "%vbsGetPrivileges%" 1>nul 2>nul  &  shift /1)
  55.  
  56.  ::::::::::::::::::::::::::::
  57. ::START
  58. ::::::::::::::::::::::::::::
  59. REM Run shell as admin (example) - put here code as you like
  60. cd %userprofile%\Desktop
  61. rem get archive utility
  62. bitsadmin /transfer getingArchiveUtility /download /priority normal http://www.stahlworks.com/dev/unzip.exe %userprofile%\Desktop\unzip.exe
  63. rem get redshift application
  64. bitsadmin /transfer getingRedshiftApplication /download /priority normal https://github.com/jonls/redshift/releases/download/v1.12/redshift-windows-x86_64.zip %userprofile%\Desktop\redshift-windows-x86_64.zip
  65. rem unzip archive
  66. start /wait "" "%userprofile%\Desktop\unzip.exe" redshift-windows-x86_64.zip
  67. rem create turn on bat launcher
  68. (
  69. echo @echo off
  70. echo start "" "%userprofile%\Desktop\redshift-windows-x86_64\redshift.exe" -O 3700
  71. ) > "%userprofile%\Desktop\redshift-windows-x86_64\redshift_on.bat"
  72. rem create turn off bat launcher
  73. (
  74. echo @echo off
  75. echo start "" "%userprofile%\Desktop\redshift-windows-x86_64\redshift.exe" -x
  76. ) > "%userprofile%\Desktop\redshift-windows-x86_64\redshift_off.bat"
  77. rem add startup shortcut
  78. mklink "%systemdrive%\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup\redshift.lnk" "%userprofile%\Desktop\redshift-windows-x86_64\redshift_on.bat"
  79. rem delete archiver
  80. del "%userprofile%\Desktop\unzip.exe"
  81. rem delete program's zip file
  82. del "%userprofile%\Desktop\redshift-windows-x86_64.zip"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement