Today I am going to fix a small creature comport (I use Google Drive to backup a drive that is not available to me 24 hours/day - as such, Google Drive errors when the drive cannot be found...and requires the application be restarted once the drive is online to resync). Easy-cheesy...use a scheduled task to run a Windows PowerShell command. Why blog about it? I have found the syntax of the command that can be a pain to work with. BONUS: Use the Start / Run command to test out your command prior to going to all the trouble to schedule it. HOWTO: call PowerShell, specify the command parameter, use the ampersand, a pair of curly brackets and the Windows PowerShell command I wish to run. Example syntax here:
Stop Google Drive Sync:
PowerShell -Command "& {Stop-Process -ProcessName googledrivesync}"
Start Google Drive Sync:
PowerShell -Command "& {Start-Process -ProcessName googledrivesync}"
1 comment:
Great bit of advice as I've been looking for a way to do exactly this for a while. One correction though. The Start-Process cmdlet doesn't have a parameter called 'ProcessName'. You would need to use FilePath to call the exe that starts the process (or add the path to your system path).
Post a Comment