You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
1.5 KiB
26 lines
1.5 KiB
5 years ago
|
import os # Get abs path of the file
|
||
|
# Create CMD str to run file if process.exe is not running
|
||
5 years ago
|
def ProcessStartIfNotRunning(inProcessName, inFilePath, inFlagGetAbsPath=True):
|
||
|
lFileAbsPath = inFilePath
|
||
|
if inFlagGetAbsPath:
|
||
|
lFileAbsPath = os.path.abspath(inFilePath)
|
||
5 years ago
|
lResult = f'tasklist /nh /fi "imagename eq {inProcessName}" | find /i "{inProcessName}" > nul || (start {lFileAbsPath})'
|
||
|
return lResult
|
||
|
# Create CMD str to stop process
|
||
5 years ago
|
def ProcessStop(inProcessName, inFlagForceClose):
|
||
5 years ago
|
lResult = f'taskkill /im "{inProcessName}" /fi "username eq %USERNAME%"'
|
||
|
if inFlagForceClose:
|
||
|
lResult+= " /F"
|
||
5 years ago
|
return lResult
|
||
|
# Send file from Host to Session RDP using shared drive in RDP (force copy)
|
||
|
def FileStoredSend(inHostFilePath, inRDPFilePath):
|
||
|
lHostFileAbsPath = os.path.join("\\\\tsclient", os.path.abspath(inHostFilePath).replace(":","")) # \\tsclient\C\path\to\file
|
||
|
lHostRDPFileAbsPath = os.path.abspath(inRDPFilePath) # File location in RDP
|
||
|
lResult = f'copy /Y "{lHostFileAbsPath}" "{lHostRDPFileAbsPath}"'
|
||
5 years ago
|
return lResult
|
||
5 years ago
|
# Send file from Session RDP to Host using shared drive in RDP (force copy)
|
||
|
def FileStoredRecieve(inRDPFilePath, inHostFilePath):
|
||
|
lHostFileAbsPath = os.path.join("\\\\tsclient", os.path.abspath(inHostFilePath).replace(":","")) # \\tsclient\C\path\to\file
|
||
|
lHostRDPFileAbsPath = os.path.abspath(inRDPFilePath) # File location in RDP
|
||
5 years ago
|
lResult = f'copy /Y "{lHostRDPFileAbsPath}" "{lHostFileAbsPath}"'
|
||
|
return lResult
|