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)
lCrosscheckKeyStr = str(random.randrange(999,9999999))
lRecoveryCMDResponsibleRetryIteratorInt = 0 # Init the retry iterator
lCommandIsTooBigBool = False
while lRecoveryCMDResponsibleRetryIteratorInt<gRecoveryCMDResponsibleRetryCountInt: # loop for retry
# # # # # # # # # # # # # OPEN WINDOW RUN # # # # # # # # # # # # # # #
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
if len(lInputStr) <= 259:
keyboard.write(lInputStr) # Write new text
time.sleep(gKeyboardHotkeyDelaySecFloat)
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. ")
# 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 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. ")
lCommandIsTooBigBool = True
keyboard.write("cmd") # Write new text
time.sleep(gKeyboardHotkeyDelaySecFloat)
# Check if autocomplete
# # # # # # #
KeyboardHotkey("ctrl", "c") # Copy data
@ -371,6 +368,14 @@ def SystemCMDRun(inSessionHexStr, inCMDCommandStr = "echo 1", inModeStr="CROSSCH
Clipboard.TextSet(lClipboardTextOld) #
time.sleep(0.5) # wait some time for the next operation
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)
lClipboardWaitTimeStartSec = time.time()
lResult["OutStr"] = Clipboard.TextGet() # Get text from clipboard

Loading…
Cancel
Save