Reputation: 13
I am looking for a way to set a schedule for OneDrive in a program I am developing. This schedule will only allow OneDrive to sync from midnight (00:00) to 6AM (06:00). The scheduling part of the program I know how to do, the part I am struggling with is finding a way to Pause the Sync at 6 AM and Resume it at midnight.
If someone could help me find a way to programmatically Pause and Resume OneDrive sync I would be grateful.
Upvotes: 1
Views: 1906
Reputation: 14896
So there are mainly 2 methods that I would go so far to archive this, let me explain you:
Here it is the command:
Invoke-WindowsApi "kernel32" ([bool]) "DebugActiveProcess" @([int]) @(process_id_here)
You will have to find the process id First (the program used by OneDrive should be SkyDrive.exe and it is under System32)
You will also have to install Invoke-WindowsApi before running that command.
You can shut down the process and then restart it at midnight, like this:
SkyDrive.exe /shutdown
SkyDrive.exe
You can create a batch for this.
Upvotes: 1