parent
fb64808f7a
commit
afe13e9417
@ -1,11 +1,13 @@
|
|||||||
import os # Get abs path of the file
|
import os # Get abs path of the file
|
||||||
# Create CMD str to run file if process.exe is not running
|
# Create CMD str to run file if process.exe is not running
|
||||||
def ProcessStartIfNotRunning(inProcessName, inFilePath):
|
def ProcessStartIfNotRunning(inProcessName, inFilePath, inFlagGetAbsPath=True):
|
||||||
lFileAbsPath = os.abspath(inFilePath)
|
lFileAbsPath = inFilePath
|
||||||
|
if inFlagGetAbsPath:
|
||||||
|
lFileAbsPath = os.path.abspath(inFilePath)
|
||||||
lResult = f'tasklist /nh /fi "imagename eq {inProcessName}" | find /i "{inProcessName}" > nul || (start {lFileAbsPath})'
|
lResult = f'tasklist /nh /fi "imagename eq {inProcessName}" | find /i "{inProcessName}" > nul || (start {lFileAbsPath})'
|
||||||
return lResult
|
return lResult
|
||||||
# Create CMD str to stop process
|
# Create CMD str to stop process
|
||||||
def ProcessStop(inProcessName, inFlagForceClose)
|
def ProcessStop(inProcessName, inFlagForceClose):
|
||||||
lResult = f'taskkill /im "{inProcessName}" /fi "username eq %USERNAME%"'
|
lResult = f'taskkill /im "{inProcessName}" /fi "username eq %USERNAME%"'
|
||||||
if inFlagForceClose:
|
if inFlagForceClose:
|
||||||
lResult+= " /F"
|
lResult+= " /F"
|
||||||
|
Loading…
Reference in new issue