-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcde_connect_google.bat
More file actions
67 lines (56 loc) · 1.5 KB
/
cde_connect_google.bat
File metadata and controls
67 lines (56 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
@echo off
setlocal enabledelayedexpansion
chcp 65001 >nul
rem check if W: has been used, delete and reconnect as new instance
echo Looking for existing W: drive...
set drive_id=""
set drive_type=""
set drive_name=""
set google_id=""
for /f "skip=1 tokens=*" %%a in ('wmic logicaldisk get deviceid^, drivetype^, volumename') do (
for /f "tokens=1-4" %%b in ("%%a") do (
if "%%b"=="W:" (
echo Found %%b ^(type=%%c, label="%%d %%e"^), removing...
set "drive_id=%%b"
set "drive_type=%%c"
set "drive_name=%%d %%e"
)
if "%%b"=="G:" (
set "google_id=%%b"
)
)
)
if not %drive_id% == "" (
if %drive_type% == 3 (
rem just for case
subst W: /D
)
if %drive_type% == 4 (
net use W: /delete /y
)
timeout /t 3 /nobreak > NUL
) else (
echo No drive W: found
)
rem connecting google drive shared disks
echo.
echo Try to establish Google Drive connection...
set "share_path[0]=G:\Shared drives"
set "share_path[1]=G:\Спільні диски"
set "share_path[2]=G:\Общие диски"
if not %google_id% == "" (
for /L %%s in (0,1,2) do (
if exist "!share_path[%%s]!" (
subst W: "!share_path[%%s]!"
timeout /t 4 /nobreak > NUL
echo Drive disk was found on G:\ and could be mounted
timeout /t 3 /nobreak > NUL
echo "!share_path[%%s]!" connected successfully
timeout /t 2 /nobreak > NUL
)
)
) else (
echo Can't find any google drive on G:, aborted
)
chcp 850 >nul
pause