Hey all Stumbled upon this little vbs that turns OneDrive on and off. Works great in 7 & 10. I wanted to modify it for other cloud apps like Dropbox and GDrive but, well, I suck at coding. Ive tried the obvious, changing the name and paths but Im just getting an error. Original OneDrive Toggle: Spoiler Code: set objWMIService = GetObject ("winmgmts:") foundProc = False procName = "OneDrive.exe" for each Process in objWMIService.InstancesOf ("Win32_Process") If StrComp(Process.Name,procName,vbTextCompare) = 0 then foundProc = True procID = Process.ProcessId End If Next If foundProc = True Then Set colProcessList = objWMIService.ExecQuery("Select * from Win32_Process where ProcessId =" & procID) For Each objProcess in colProcessList objProcess.Terminate() Next WScript.Sleep(1000) 'wait for a second Set colProcessList = objWMIService.ExecQuery("Select * from Win32_Process where ProcessId =" & procID) If colProcessList.count = 0 Then msgbox "OneDrive is now closed.", 0 & 64,"OneDrive" End If else WScript.CreateObject("WScript.Shell").Run("%LocalAppData%\Microsoft\OneDrive\OneDrive.exe") End If Attempt at Dropbox: (ninite installer paths, think normal installs elsewhere) Spoiler Code: set objWMIService = GetObject ("winmgmts:") foundProc = False procName = "Dropbox.exe" for each Process in objWMIService.InstancesOf ("Win32_Process") If StrComp(Process.Name,procName,vbTextCompare) = 0 then foundProc = True procID = Process.ProcessId End If Next If foundProc = True Then Set colProcessList = objWMIService.ExecQuery("Select * from Win32_Process where ProcessId =" & procID) For Each objProcess in colProcessList objProcess.Terminate() Next WScript.Sleep(1000) 'wait for a second Set colProcessList = objWMIService.ExecQuery("Select * from Win32_Process where ProcessId =" & procID) If colProcessList.count = 0 Then msgbox "Dropbox is now closed.", 0 & 64,"Dropbox" End If else WScript.CreateObject("WScript.Shell").Run("C:\Program Files (x86)\Dropbox\Client\Dropbox.exe") End If Attempt at GDrive: Spoiler Code: set objWMIService = GetObject ("winmgmts:") foundProc = False procName = "googledrivesync.exe" for each Process in objWMIService.InstancesOf ("Win32_Process") If StrComp(Process.Name,procName,vbTextCompare) = 0 then foundProc = True procID = Process.ProcessId End If Next If foundProc = True Then Set colProcessList = objWMIService.ExecQuery("Select * from Win32_Process where ProcessId =" & procID) For Each objProcess in colProcessList objProcess.Terminate() Next WScript.Sleep(1000) 'wait for a second Set colProcessList = objWMIService.ExecQuery("Select * from Win32_Process where ProcessId =" & procID) If colProcessList.count = 0 Then msgbox "Googel Drive is now closed.", 0 & 64,"OneDrive" End If else WScript.CreateObject("WScript.Shell").Run("C:\Program Files\Google\Drive\googledrivesync.exe") End If Attempt at Skype: Spoiler Code: set objWMIService = GetObject ("winmgmts:") foundProc = False procName = "Skype.exe" for each Process in objWMIService.InstancesOf ("Win32_Process") If StrComp(Process.Name,procName,vbTextCompare) = 0 then foundProc = True procID = Process.ProcessId End If Next If foundProc = True Then Set colProcessList = objWMIService.ExecQuery("Select * from Win32_Process where ProcessId =" & procID) For Each objProcess in colProcessList objProcess.Terminate() Next WScript.Sleep(1000) 'wait for a second Set colProcessList = objWMIService.ExecQuery("Select * from Win32_Process where ProcessId =" & procID) If colProcessList.count = 0 Then msgbox "Skype is now closed.", 0 & 64,"Skype" End If else WScript.CreateObject("WScript.Shell").Run("C:\Program Files (x86)\Skype\Phone\Skype.exe") End If Basically, if the app is running it closes it and if it isnt it starts it up. At a loss really, its all a foreign language to me If any one could point out whats wrong it would be much appreciated!
Enclose the paths containing spaces with double quotes like this... Dropbox: Spoiler Code: WScript.CreateObject("WScript.Shell").Run("""%ProgramFiles(x86)%\Dropbox\Client\Dropbox.exe""") OR Code: WScript.CreateObject("WScript.Shell").Run("""C:\Program Files (x86)\Dropbox\Client\Dropbox.exe""") GDrive: Spoiler Code: WScript.CreateObject("WScript.Shell").Run("""%ProgramFiles%\Google\Drive\googledrivesync.exe""") OR Code: WScript.CreateObject("WScript.Shell").Run("""C:\Program Files\Google\Drive\googledrivesync.exe""") Skype: Spoiler Code: WScript.CreateObject("WScript.Shell").Run("""%ProgramFiles(x86)%\Skype\Phone\Skype.exe""") OR Code: WScript.CreateObject("WScript.Shell").Run("""C:\Program Files (x86)\Skype\Phone\Skype.exe""") Hope this helps!