0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Googleドライブ接続確認

Last updated at Posted at 2025-03-25

Googleドライブが導入されて
自分のパソコンが壊れても
他のパソコンでアクセス出来ると
喜んでいたのですが

今の環境だと
デスクトップ画面が出てから
3分程、経過しないと
Googleドライブが使えません

そこで
Gemini 先生や Copilot 先生に
教えを請いながら
Googleドライブの
接続が確立された事を確認する
バッチを作成しました
ANSI【Sjis】で保存して下さい

PowerShell の Get-WmiObject で
未接続 ⇒ Null が 返ってくる
接続済 ⇒ D: 等 の ドライブレター が 返ってくる
で判断しています

スタートアップに入れて
接続確認をするとか
タスクバーにGoogleドライブの
アイコンを出したくない場合に
単品で使用して確認するなどが
主な使用目的です

接続が確立された事を利用して
そのままGoogleドライブにある
アプリ等の立ち上げも可能になります

Googleドライブ接続確認.cmd
@echo off
Title %~n0 %time:~0,-3%  開始

rem /;
rem /; ★ Googleドライブ接続確認
rem /;
rem /;    explorer shell:Startup を ファイル名を指定して実行に貼り付けて [ Enter ] 後
rem /;    開かれた スタートアップ フォルダ に Googleドライブ接続確認.cmd を コピー する
rem /;
rem /;    バッチの最終行にある rem を 消すと
rem /;    rem /; explorer      "%Google_Drive_Letter%"
rem /;    ↓
rem /;    explorer      "%Google_Drive_Letter%"
rem /;
rem /;    接続が完了してから エクスプローラー で Googleドライブ を 開きます
rem /;

echo;
echo; Googleドライブ接続を待機中..
echo;

set            "Google_Drive_Letter="

  :Wait_Connect_Google_Drive

for /f "delims=" %%0 in ('PowerShell -command "(Get-WmiObject -Class Win32_LogicalDisk | Where-Object { $_.VolumeName -eq """Google Drive""" }).DeviceID"') do set "Google_Drive_Letter=%%0"

if  not DEFINED Google_Drive_Letter ping -n 30 localhost >NUL & for /f "tokens=1-6 delims=/:-" %%1 in ('Powershell -command Get-Date -Format "yyyy/MM/dd-HH:mm:ss"') do @echo; %%1/%%2/%%3 %%4:%%5:%%6 現在、接続待機中 & goto :Wait_Connect_Google_Drive

echo;
echo; Googleドライブ接続されました
echo;
echo; このウインドウは 60 秒後 に 閉じられます
ping -n                60 localhost >NUL

rem /; explorer      "%Google_Drive_Letter%"
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?