I am attempting to create a script (within Procedures) that will trigger a resync for Onedrive, then reopen Onedrive on the client (I plan to schedule this a couple times a week). I believe I have added the appropriate commands to accomplish, but am getting an error about Onedrive not allowing the Administrator to open OneDrive. The script seems to run fine, closes Onedrive, then attempts to reopen Onedrive but Windows throws an error:
OneDrive can’t be run using full administrator rights. Please restart Onedrive without administrator rights.
- When running the script I am selecting run As LoggedInUser (Which is in the administrators group if that matters) rather than Run as LocalSystemUser.
Below is the script bold where the changes were made tot he default:
#To define a particular parameter, replace the ‘parameterName’ inside itsm.getParameter(‘parameterName’) with that parameter’s name
command=r’%localappdata%\Microsoft\OneDrive\onedrive.exe /reset & %localappdata%\Microsoft\OneDrive\onedrive.exe’ #Please edit your command here.
import ctypes
from subprocess import PIPE, Popen
def ecmd(command):
class disable_file_system_redirection:
_disable = ctypes.windll.kernel32.Wow64DisableWow64FsRedirect ion
_revert = ctypes.windll.kernel32.Wow64RevertWow64FsRedirecti on
def enter(self):
self.old_value = ctypes.c_long()
self.success = self._disable(ctypes.byref(self.old_value))
def exit(self, type, value, traceback):
if self.success:
self._revert(self.old_value)
with disable_file_system_redirection():
obj = Popen(command, shell = True, stdout = PIPE, stderr = PIPE)
out, err = obj.communicate()
ret=obj.returncode
if ret==0:
if out:
return out.strip()
else:
return ret
else:
if err:
return err.strip()
else:
return ret
print ecmd(command)
Any help would be appreciated.
Thanks,