Advertisement
Guest User

Untitled

a guest
Feb 18th, 2018
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 7.82 KB | None | 0 0
  1. @echo off
  2. :: BatchGotAdmin
  3. :-------------------------------------
  4. mkdir "%windir%\BatchGotAdmin"
  5. if '%errorlevel%' == '0' (
  6.   rmdir "%windir%\BatchGotAdmin" & goto gotAdmin
  7. ) else ( goto UACPrompt )
  8.  
  9. :UACPrompt
  10.     echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
  11.     echo UAC.ShellExecute %0, "", "", "runas", 1 >> "%temp%\getadmin.vbs"
  12.  
  13.     "%temp%\getadmin.vbs"
  14.     exit /B
  15.  
  16. :gotAdmin
  17.     if exist "%temp%\getadmin.vbs" ( del "%temp%\getadmin.vbs" )
  18.     pushd "%CD%"      
  19.     CD /D "%~dp0""
  20. :--------------------------------------
  21. echo Sandboxie Installer Started
  22.  
  23. ::==========================================
  24. :: [ Check for Sandboxie Installation ]
  25. ::==========================================
  26. set sandboxieDir=%programfiles%\Sandboxie
  27.  
  28. echo.
  29. echo - Checking for Sandboxie installation...
  30.  
  31. if exist "%sandboxieDir%" (
  32.  color 2f
  33.  echo - Found Sandboxie Installation.
  34. ) else (
  35.  color 4f
  36.  echo - ERROR: Sandboxie does not appear to be installed.
  37.  pause
  38.  goto end
  39. )
  40.  
  41. ::==========================================
  42. :: [ Configure Sandboxie Directories ]
  43. ::==========================================
  44. set sandboxieConfigFile="C:\windows\Sandboxie.ini"
  45. if not exist "C:\windows\Sandboxie.ini" (
  46.     set sandboxieConfigFile="%programfiles%\Sandboxie.ini"
  47. )
  48.  
  49. :: Folder path of sandboxie default sandbox path (location of sandboxes)
  50. set sandboxDir=C:\Sandbox\%username%
  51.  
  52. ::==========================================
  53. :: [ Configure Sandbox Application ]
  54. ::==========================================
  55.  
  56. ::
  57. :: The name the VM will be called and the name of the template folder (no spaces)
  58. set sandboxName=Firefox
  59. set sandboxToRunIn=Firefox
  60.  
  61. :: For start menu and desktop shortcuts
  62. set appStartMenuFolder=Mozilla Firefox
  63. set appName=Mozilla Firefox
  64.  
  65.  
  66. :: Various options for vm
  67. set appExePath=%sandboxDir%\%sandboxName%\drive\C\Program Files\Mozilla Firefox\firefox.exe
  68. set appIconPath=%appExePath%
  69. set appIconNumber=0
  70.  
  71. ::==========================================
  72. :: [ Terminate Running Sandbox Application ]
  73. ::==========================================
  74. start "" "%sandboxieDir%\start.exe" /box:%sandboxName% /terminate
  75. if %sandboxToRunIn% neq %sandboxName (
  76.   start "" "%sandboxieDir%\start.exe" /box:%sandboxToRunIn% /terminate
  77. )
  78. timeout 1
  79.  
  80. start "" "%sandboxieDir%\start.exe" /box:%sandboxName% delete_sandbox
  81. timeout 2
  82. if %sandboxToRunIn% neq %sandboxName (
  83.   start "" "%sandboxieDir%\start.exe" /box:%sandboxToRunIn% delete_sandbox
  84.   timeout 1
  85. )
  86.  
  87. ::==========================================
  88. :: [ Install Application ]
  89. ::==========================================
  90. echo - Copying template sandbox to live sandbox directory
  91. if %sandboxToRunIn% neq %sandboxName (
  92.   rd /S /q %sandboxDir%\%sandboxToRunIn%
  93. )
  94. rd /S /q %sandboxDir%\%sandboxName%
  95. md /S /q %sandboxDir%\%sandboxName%
  96. robocopy "%cd%\%sandboxName%" %sandboxDir%\%sandboxName% /E /W:5
  97.  
  98. if %sandboxToRunIn% neq %sandboxName (
  99.   robocopy "%cd%\%sandboxToRunIn%" %sandboxDir%\%sandboxToRunIn% /E /W:5
  100. )
  101.  
  102.  
  103. echo - Creating Desktop shortcuts...
  104. call :CreateDesktopShortcut
  105.  
  106. echo - Creating Start Menu shortcuts...
  107. call :CreateStartMenuShortcut
  108.  
  109. echo - Creating Sandboxie Configuration Entries For %sandboxName%
  110. call :CreateSandbox
  111.  
  112. ::==========================================
  113. :: [ Exit Installer ]
  114. ::==========================================
  115. echo Installation Completed!
  116.  
  117. :end
  118. echo.
  119. echo The installer will now exit.
  120. pause
  121. exit /b
  122. goto:eof
  123.  
  124. :: =================================================================================================================================
  125. :: =================================================================================================================================
  126. :: =================================================================================================================================
  127.  
  128. ::==========================================
  129. :: Functions
  130. ::==========================================
  131.  
  132. :CreateDesktopShortcut
  133.     echo   - Creating desktop shortcut for %appName%...
  134.    
  135.     echo Set oWS = WScript.CreateObject("WScript.Shell") > "%temp%\CreateShortcut.vbs"
  136.     (
  137.         echo sLinkFile = "%userprofile%\Desktop\%appName%.lnk"
  138.         echo Set oLink = oWS.CreateShortcut^(sLinkFile^)
  139.         echo oLink.TargetPath = "%sandboxieDir%\start.exe"
  140.         echo oLink.Arguments = "/box:%sandboxToRunIn% %appExePath%"
  141.         echo oLink.IconLocation = "%appIconPath%"
  142.         echo oLink.Save
  143.     ) >> "%temp%\CreateShortcut.vbs"
  144.  
  145.     rem Extras
  146.     rem oLink.WindowStyle = "1"  
  147.     rem oLink.WorkingDirectory = "C:\Program Files\MyApp"
  148.     rem oLink.Description = "MyProgram"  
  149.     rem oLink.HotKey = "ALT+CTRL+F"
  150.  
  151.     cscript "%temp%\CreateShortcut.vbs" > nul
  152.     del "%temp%\CreateShortcut.vbs" > nul
  153. goto:eof
  154.  
  155. :CreateStartMenuShortcut
  156.     echo   - Creating Start Menu entry for %appName%...
  157.     if not exist "%userprofile%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\%appStartMenuFolder%" ( mkdir "%userprofile%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\%appStartMenuFolder%" )
  158.  
  159.     echo Set oWS = WScript.CreateObject("WScript.Shell") > "%temp%\CreateShortcut.vbs"
  160.     (
  161.         echo sLinkFile = "%userprofile%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\%appStartMenuFolder%\%appName%.lnk"
  162.         echo Set oLink = oWS.CreateShortcut^(sLinkFile^)
  163.         echo oLink.TargetPath = "%sandboxieDir%\start.exe"
  164.         echo oLink.Arguments = "/box:%sandboxToRunIn% %appExePath%"
  165.         echo oLink.IconLocation = "%appIconPath%"
  166.         echo oLink.Save
  167.     ) >> "%temp%\CreateShortcut.vbs"
  168.  
  169.     cscript "%temp%\CreateShortcut.vbs" > nul
  170.     del "%temp%\CreateShortcut.vbs" > nul
  171. goto:eof
  172.  
  173. :CreateSandbox
  174.     start "" "%sandboxieDir%\sbieini.exe" set %sandboxName% Enabled y
  175.     start "" "%sandboxieDir%\sbieini.exe" set %sandboxName% OpenPipePath=Reflector.exe,\Device\NamedPipe\SandboxieReflectorCommands
  176.     start "" "%sandboxieDir%\sbieini.exe" set %sandboxName% ConfigLevel=7
  177.     start "" "%sandboxieDir%\sbieini.exe" set %sandboxName% AutoRecover=y
  178.     start "" "%sandboxieDir%\sbieini.exe" set %sandboxName% Template=WindowsFontCache
  179.     start "" "%sandboxieDir%\sbieini.exe" set %sandboxName% Template=BlockPorts
  180.     start "" "%sandboxieDir%\sbieini.exe" set %sandboxName% Template=LingerPrograms
  181.     start "" "%sandboxieDir%\sbieini.exe" set %sandboxName% Template=AutoRecoverIgnore
  182.     start "" "%sandboxieDir%\sbieini.exe" set %sandboxName% RecoverFolder=%Personal%
  183.     start "" "%sandboxieDir%\sbieini.exe" set %sandboxName% RecoverFolder=%Personal%\Downloads
  184.     start "" "%sandboxieDir%\sbieini.exe" set %sandboxName% RecoverFolder=%Favorites%
  185.     start "" "%sandboxieDir%\sbieini.exe" set %sandboxName% RecoverFolder=%Desktop%
  186.     start "" "%sandboxieDir%\sbieini.exe" set %sandboxName% BorderColor=#00FFFF,ttl
  187.  
  188.     start "" "%sandboxieDir%\sbieini.exe" set %sandboxToRunIn% Enabled y
  189.     start "" "%sandboxieDir%\sbieini.exe" set %sandboxToRunIn% OpenPipePath=Reflector.exe,\Device\NamedPipe\SandboxieReflectorCommands
  190.     start "" "%sandboxieDir%\sbieini.exe" set %sandboxToRunIn% ConfigLevel=7
  191.     start "" "%sandboxieDir%\sbieini.exe" set %sandboxToRunIn% AutoRecover=y
  192.     start "" "%sandboxieDir%\sbieini.exe" set %sandboxToRunIn% Template=WindowsFontCache
  193.     start "" "%sandboxieDir%\sbieini.exe" set %sandboxToRunIn% Template=BlockPorts
  194.     start "" "%sandboxieDir%\sbieini.exe" set %sandboxToRunIn% Template=LingerPrograms
  195.     start "" "%sandboxieDir%\sbieini.exe" set %sandboxToRunIn% Template=AutoRecoverIgnore
  196.     start "" "%sandboxieDir%\sbieini.exe" set %sandboxToRunIn% RecoverFolder=%Personal%
  197.     start "" "%sandboxieDir%\sbieini.exe" set %sandboxToRunIn% RecoverFolder=%Personal%\Downloads
  198.     start "" "%sandboxieDir%\sbieini.exe" set %sandboxToRunIn% RecoverFolder=%Favorites%
  199.     start "" "%sandboxieDir%\sbieini.exe" set %sandboxToRunIn% RecoverFolder=%Desktop%
  200.     start "" "%sandboxieDir%\sbieini.exe" set %sandboxToRunIn% BorderColor=#00FFFF,ttl
  201.  
  202.  
  203.     start "" "%sandboxieDir%\start.exe" /reload
  204. goto:eof
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement