RDP.SystemCMDRun - 2 fix if command string is more than 259 symb - not applicable for RUN window - need to open CMD and type!

dev-linux
Ivan Maslov 4 years ago
parent 51c916a0e7
commit 137ec89fc2

@ -306,6 +306,7 @@ def SystemCMDRun(inSessionHexStr, inCMDCommandStr = "echo 1", inModeStr="CROSSCH
Clipboard.TextSet(lClipboardTextOld) Clipboard.TextSet(lClipboardTextOld)
lCrosscheckKeyStr = str(random.randrange(999,9999999)) lCrosscheckKeyStr = str(random.randrange(999,9999999))
lRecoveryCMDResponsibleRetryIteratorInt = 0 # Init the retry iterator lRecoveryCMDResponsibleRetryIteratorInt = 0 # Init the retry iterator
lCommandIsTooBigBool = False
while lRecoveryCMDResponsibleRetryIteratorInt<gRecoveryCMDResponsibleRetryCountInt: # loop for retry while lRecoveryCMDResponsibleRetryIteratorInt<gRecoveryCMDResponsibleRetryCountInt: # loop for retry
# # # # # # # # # # # # # OPEN WINDOW RUN # # # # # # # # # # # # # # # # # # # # # # # # # # # # OPEN WINDOW RUN # # # # # # # # # # # # # # #
lRecoveryWindowRUNRetryIteratorInt = 0 # Init the retry iterator lRecoveryWindowRUNRetryIteratorInt = 0 # Init the retry iterator
@ -327,16 +328,12 @@ def SystemCMDRun(inSessionHexStr, inCMDCommandStr = "echo 1", inModeStr="CROSSCH
lInputStr = f"cmd /c ({inCMDCommandStr}) {lCMDPostFixStr}" # Generate the output string for RUN window lInputStr = f"cmd /c ({inCMDCommandStr}) {lCMDPostFixStr}" # Generate the output string for RUN window
if len(lInputStr) <= 259: if len(lInputStr) <= 259:
keyboard.write(lInputStr) # Write new text keyboard.write(lInputStr) # Write new text
time.sleep(gKeyboardHotkeyDelaySecFloat)
else: else:
if lL: lL.warning(f"RDP.SystemCMDRun: ATTENTION! Your command is too big for the RUN window (len is {len(lInputStr)}. Orchestrator will send this command to the new cmd window. ") if lL: lL.warning(
# Case when string is tool big - call cmd and then type text into f"RDP.SystemCMDRun: ATTENTION! Your command is too big for the RUN window (len is {len(lInputStr)}. Orchestrator will send this command to the new cmd window. ")
keyboard.write("cmd") # Open cmd lCommandIsTooBigBool = True
time.sleep(1) keyboard.write("cmd") # Write new text
keyboard.press_and_release('enter') # Execute CMD time.sleep(gKeyboardHotkeyDelaySecFloat)
keyboard.write(f"({inCMDCommandStr}) {lCMDPostFixStr}", delay= 0.05) # send command
time.sleep(1)
keyboard.press_and_release('enter') # Execute command
# Check if autocomplete # Check if autocomplete
# # # # # # # # # # # # # #
KeyboardHotkey("ctrl", "c") # Copy data KeyboardHotkey("ctrl", "c") # Copy data
@ -371,6 +368,14 @@ def SystemCMDRun(inSessionHexStr, inCMDCommandStr = "echo 1", inModeStr="CROSSCH
Clipboard.TextSet(lClipboardTextOld) # Clipboard.TextSet(lClipboardTextOld) #
time.sleep(0.5) # wait some time for the next operation time.sleep(0.5) # wait some time for the next operation
keyboard.press_and_release('enter') # Execute CMD keyboard.press_and_release('enter') # Execute CMD
if lCommandIsTooBigBool == True:
# Case when string is tool big - call cmd and then type text into
#keyboard.write("cmd") # Open cmd
#time.sleep(1)
#keyboard.press_and_release('enter') # Execute CMD
keyboard.write(f"({inCMDCommandStr}) {lCMDPostFixStr}", delay=0.05) # send command
time.sleep(1)
keyboard.press_and_release('enter') # Execute command
if inModeStr == "CROSSCHECK" or inModeStr == "LISTEN": # Get OutStr (Case CROSSCHECK and LISTEN) if inModeStr == "CROSSCHECK" or inModeStr == "LISTEN": # Get OutStr (Case CROSSCHECK and LISTEN)
lClipboardWaitTimeStartSec = time.time() lClipboardWaitTimeStartSec = time.time()
lResult["OutStr"] = Clipboard.TextGet() # Get text from clipboard lResult["OutStr"] = Clipboard.TextGet() # Get text from clipboard

Loading…
Cancel
Save