Last active
June 26, 2019 09:14
-
-
Save redneck-f25/00d560bcc35cd70e2efcc6f25a1bf536 to your computer and use it in GitHub Desktop.
Mount Strato HiDrive as network drive
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off & setlocal enableextensions enabledelayedexpansion | |
rem *************************************************************************** | |
rem * MountHiDrive.cmd * | |
rem * * | |
rem * Mount Strato HiDrive as network drive * | |
rem * * | |
rem * Copyright (C) 2019 BitCtrl Systems GmbH * | |
rem * @author Daniel Hammerschmidt <[email protected]> * | |
rem * @date 2019-06-25 * | |
rem * * | |
rem * NOTE: Take care of special chars in passwords. * | |
rem * i.e. precede an exclamation mark with three carets ^^^! * | |
rem *************************************************************************** | |
rem * Alternative: KeePass2 cmd-URL * | |
rem * (set net_drive as string field in the advanced tab) * | |
rem * * | |
rem * WEBDAV: * | |
rem * cmd://cmd /c "net use {s:net_drive} https://{USERNAME}.webdav.hidrive.strato.com /user:{USERNAME} {PASSWORD} && reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\MountPoints2\##{USERNAME}.webdav.hidrive.strato.com@SSL#DavWWWRoot /v _LabelFromReg /d {USERNAME}@HiDrive /f && explorer /n,/e,{s:net_drive}\users\{USERNAME} & pause & net use /delete {s:net_drive}" | |
rem * * | |
rem * CIFS: * | |
rem * cmd://cmd /c "net use {s:net_drive} \\{USERNAME}.cifs.hidrive.strato.com\root /user:{USERNAME} {PASSWORD} && reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\MountPoints2\##{USERNAME}.cifs.hidrive.strato.com#root /v _LabelFromReg /d {USERNAME}@HiDrive /f && explorer /n,/e,{s:net_drive}\users\{USERNAME} & pause & net use /delete {s:net_drive}" | |
rem *************************************************************************** | |
if "%~1" == "" ( | |
set "conf_file=%~dpn0.conf.cmd" | |
) else ( | |
set "conf_file=%~dp0%~1.conf.cmd" | |
) | |
if not exist "%conf_file%" ( | |
if "%~1" == "" ( | |
set /p "name=Enter name for config-file: " | |
if not "!name!" == "" ( | |
>"%~dpn0-!name!.cmd" echo\@"%%~dp0%~nx0" "%%~n0" | |
"%~dpn0-!name!.cmd" | |
exit /b | |
) | |
) | |
( | |
echo\set "HIDRIVE_LETTER=S:" | |
echo\set "HIDRIVE_PROTOCOL=webdav" | |
echo\set "HIDRIVE_USERNAME=" | |
echo\set "HIDRIVE_PASSWORD=" | |
) >"%conf_file%" | |
start /wait notepad "%conf_file%" | |
) | |
call "%conf_file%" | |
set "netdrive=%HIDRIVE_LETTER:~0,1%:" | |
set "hostname=%HIDRIVE_USERNAME%.%HIDRIVE_PROTOCOL%.hidrive.strato.com" | |
title %~n0 - %hostname% | |
if "%HIDRIVE_PROTOCOL%" == "webdav" ( | |
set "netpath=https://%hostname%" | |
set "mountpoint=##%hostname%@SSL#DavWWWRoot" | |
) else if "%HIDRIVE_PROTOCOL%" == "cifs" ( | |
set "netpath=\\%hostname%\root" | |
set "mountpoint=##%hostname%#root" | |
) | |
set "regkey=HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\MountPoints2\%mountpoint%" | |
net use %netdrive% %netpath% /user:%HIDRIVE_USERNAME% "%HIDRIVE_PASSWORD%" && ( | |
reg add "%regkey%" /v _LabelFromReg /d "%HIDRIVE_USERNAME%@HiDrive" /f | |
explorer /n,/e,%netdrive%\users\%HIDRIVE_USERNAME% | |
) | |
echo\ | |
set /p "_=Press Return to disconnect or close this window if you want to do this manually." | |
net use /delete %HIDRIVE_LETTER:~0,1%: | |
ping -n 3 localhost >nul 2>nul |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off & setlocal enableextensions enabledelayedexpansion & goto __early__ | |
rem *************************************************************************** | |
rem * WebClientServiceConfig.cmd * | |
rem * * | |
rem * Configure WebClient servicet to download files up to 4GiB. * | |
rem * * | |
rem * Copyright (C) 2019 BitCtrl Systems GmbH * | |
rem * @author Daniel Hammerschmidt <[email protected]> * | |
rem * @date 2019-06-26 * | |
rem *************************************************************************** | |
:__config__ | |
goto __main__ | |
:__early__ | |
net session >nul 2>nul || ( | |
where SuRun.exe >nul 2>nul && ( | |
SuRun.exe "%~f0" | |
exit /b | |
) | |
color 4f | |
echo\Need administrative permissions. | |
pause | |
color | |
exit /b 1 | |
) | |
goto __config__ | |
:__main__ | |
sc query WebClient | |
echo\ | |
for /f "usebackq tokens=1-4 delims=: " %%a in ( `sc query WebClient` ) do ( | |
if "%%a:%%b:%%c" == "STATE:4:RUNNING" sc stop WebClient >nul | |
) | |
<nul set /p "_=Stop WebClient service " | |
:wait_stopped | |
<nul set /p "_=." | |
ping -n 2 localhost >nul 2>nul | |
for /f "usebackq tokens=1-4 delims=: " %%a in ( `sc query WebClient` ) do ( | |
if "%%a" == "STATE" if not "%%b:%%c" == "1:STOPPED" goto wait_stopped | |
) | |
echo\ | |
echo\ | |
set "regkey=HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WebClient\Parameters" | |
set "_4GiB=4294967295" | |
echo Set parameters FileSizeLimitInBytes and FileAttributesLimitInBytes to 4GiB | |
reg add "%regkey%" /v FileSizeLimitInBytes /t REG_DWORD /d %_4GiB% /f | |
reg add "%regkey%" /v FileAttributesLimitInBytes /t REG_DWORD /d %_4GiB% /f | |
echo\ | |
<nul set /p "_=Start WebClient service " | |
sc start WebClient >nul | |
:wait_started | |
<nul set /p "_=." | |
ping -n 2 localhost >nul 2>nul | |
for /f "usebackq tokens=1-4 delims=: " %%a in ( `sc query WebClient` ) do ( | |
if "%%a" == "STATE" if not "%%b:%%c" == "4:RUNNING" goto wait_started | |
) | |
echo\ | |
echo\ | |
sc query WebClient | |
pause |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment