So i made a script that finds microsoft.sharepoint.exe's PID and closes it.
But the problem is if another user is logged into the computer, they'll have an instance of microsoft.sharepoint.exe running as well. My script will see that, try to close it, fail, and wintegrate can't open. I can manually go into task manager and close the process, but that defeats the purpose of my automation. And running my script as administrator doesn't work either.
Does anyone know how to end processes running under other users? Or how to end processes under only my user, that might also work but I'm not sure.
Here's what I have so far which can end microsoft.sharepoint.exe processes under my user but only as long as I'm alphabetically first in task manager, which I never am unless I'm on the only user signed on.
Code: Select all
processToClose = Microsoft.SharePoint.exe
Loop
{
if (A_index = 50)
{
errorState = 1
break
}
SetTitleMatchMode 2
Process Exist, %processToClose%
PID := ErrorLevel
;msgbox, PID = %PID%
if (PID = "0")
{
break
}
Process, close, %PID%
}
if (errorState = "1")
{
msgbox, failed to close all instances of %processToClose%
}
else
{
msgbox, All instances of %processToClose% have been closed.
}