ZTree.com  | ZEN  | About...  

 Index   Back

[Help!] Batch file to detect changing Google Drive startup ...   [Help!]

By: Ben Kent       
Date: Dec 17,2023 at 17:32
In Response to: [Help!] Batch file to detect changing Google Drive startup program version number (Andrew Watson)

> I was wondering if any of the batch file gurus here could devise some
> code that could automatically detect the latest version number and run
> that version?

Andrew


To find the location of OneDrive.exe, you could do this

Set ONEDRIVESTART=
for /f "tokens=2,*" %%I in ('reg.exe query "HKCUSOFTWAREClassesodopenDefaultIcon" /ve ^| find "REG_SZ"') do Set "ONEDRIVESTART=%%J"
If Defined ONEDRIVESTART Set ONEDRIVESTART="%ONEDRIVESTART%" /background
If Not Defined ONEDRIVESTART Echo Failed to find OneDrive

Also these registry locations could be used
"HKCUSOFTWAREMicrosoftOneDrive" /v "OneDriveTrigger"
"HKCUSOFTWAREMicrosoftWindowsCurrentVersionRun" /v "OneDrive"



There are probably registry pointers to GoogleDriveFS.exe, if not then you could use this method

Set GOOGLEDRIVESTART=
For /F "tokens=1" %%I in ('dir /s /a-d /b /od "C:Program FilesGoogleDrive File StreamGoogleDriveFS.exe"') do Set "GOOGLEDRIVESTART=%%I"
If Defined GOOGLEDRIVESTART Set GOOGLEDRIVESTART="%GOOGLEDRIVESTART%" --startup_mode
If Not Defined GOOGLEDRIVESTART Echo Failed to find Google Drive File Stream



Also
As the drive letter for removable drives can change, if you ensure that each removable drive has a unique label, then this can be used to find the drive.

Set FoundDrive=
Set DriveLabel=DataDrive
for %%A in (A: B: C: D: E: F: G: H: I: J: K: L: M:) do for /f "tokens=5,*" %%I in ('dir %%A 2^>nul ^| find " Volume in drive " ^| find "%DriveLabel%"') do if not ""=="%%J" Set FoundDrive=%%A
If not defined FoundDrive Echo Failed to find drive %DriveLabel%


Ben

208 views      
 

Messages in this Thread

 
96,656 Postings in 12,233 Threads, 350 registered users, 33 users online (0 registered, 33 guests)
Index | Admin contact |   Forum Time: May 18, 2024 - 12:41 pm UTC  |  Hits:63,519,126  (3,830 Today )
RSS Feed