Jump to content
fopetesl

Run(Wait) failures

Recommended Posts

fopetesl

If I run "stripcat scandataF.dta" (or scandataF.bat which has same script) from command line it works without error but if I run from AutoIt script it fails

I have tried

; > not work    $DOS = RunWait(@ComSpec & ' /c "stripcat.exe "scandataF.dta' & @CRLF, "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
;   $DOS = RunWait(@ComSpec & " /k " & "scandataF.bat" & @CRLF, "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
;  Run("scandataF.bat")

The "not work" line doesn't throw any error but also doesn't function. Both Run & RunWait do throw the Micro$oft error.

Stripcat_Error.jpg


The most powerful number in the Universe.  Zero.

Share this post


Link to post
Share on other sites
Subz

Not sure why you have an carriage return in your string and also not sure about your quotes, have you tried:

RunWait(@ComSpec & ' /c stripcat.exe scandataF.dta', "<Path to stripcat.exe>")
Or
RunWait(@ComSpec & ' /c "<Path to Stripcat.exe>" "<Path to ScanDataF.dta"')
Or
ShellExecute("Stripcat.exe", "scandataF.dta")
  • Like 1

Share this post


Link to post
Share on other sites
fopetesl

Thanks, Subz. No.3 seems to work without error.

So what's the difference between 'Run' & 'ShellExecute'?

SE uses an API and Run doesn't?  Should I always use SE rather than Run?


The most powerful number in the Universe.  Zero.

Share this post


Link to post
Share on other sites
fopetesl

Correction! No. It doesn't work.

Take this:

$DOS = Run(@ComSpec & " /k " & "ncat 192.168.1.6 80 <getdata >scan1.dta", "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
  $DOS = Run(@ComSpec & " /k " & "ncat 192.168.1.6 80 <getdata >scan2.dta", "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
  If( $scanmode <> "baseline") Then
   ShellExecute("Stripcat.exe", "scandataF.dta") ; this has Micro$oft error
  Else
   ShellExecute("Stripcat.exe", "baseline.dta") ; this has Micro$oft error
  EndIf
; now reverse scan...
  $DOS = Run(@ComSpec & " /k " & "ncat 192.168.1.6 80 <scanr >scanrep", "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
  ProgressOn("Scanning Home", "Scan Progress ...", "Working...")
              For $i = 140 TO 0 Step -1
                ProgressSet($i)
                Sleep(100)
              Next
              ProgressSet(100, "Complete!")
              Sleep(500)
              ProgressOff()
  $DOS = Run(@ComSpec & " /k " & "ncat 192.168.1.6 80 <getdata >scan1.dta", "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
  $DOS = Run(@ComSpec & " /k " & "ncat 192.168.1.6 80 <getdata >scan2.dta", "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
  ShellExecute("Stripcat.exe", "scandataR.dta"); this does not have Micro$oft error
                               ; & works as expected
  If( $scanmode <> "baseline") Then
    $DOS = Run(@ComSpec & " /k " & "hbinterpret" & @CRLF, "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) 
  EndIf

It did work initially. Now it errors every time. :(

Edited by fopetesl
Now fails

The most powerful number in the Universe.  Zero.

Share this post


Link to post
Share on other sites
fopetesl

Is running on XP, so Wow64 is relevant?

 


The most powerful number in the Universe.  Zero.

Share this post


Link to post
Share on other sites
spudw2k

Right, not relevant for XP.

I do find it curious that your third ShellExecute works...I would suspect Stripcat doesn't like something about the first two dta files since there is nothing intrinsically different from an AutoIt perspective about the ShellExecute function calls other than the destination file (scandataF.dta, baseline.dta, scandataR.dta).  

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Similar Content

    • Fortitude
      By Fortitude
      Hello!
      I have made a program, that opens a folder, and then store the path ("C:\programFiles\etc") in a variable.
      Then i need to open the command panel as administrator, and write  in the stored path, and some other text.

      Can i somehow instantly copypaste the text i needed, instead of writing in the command panel with the Send commands?
       
      #RequireAdmin #include <MsgBoxConstants.au3> Global Const $sMessage = "Select a folder" ; Display an open dialog to select a file. Global $sFileSelectFolder = FileSelectFolder($sMessage, "") If @error Then MsgBox($MB_SYSTEMMODAL, "", "Nem választottál ki mappát!") Exit EndIf Global $Tiff_path = $sFileSelectFolder & "\TiffChecker_2_32" FileCopy( "C:\TiffChecker_2_32.exe" , $sFileSelectFolder) $CMD = $Tiff_path & " " & $sFileSelectFolder & " /s/d" Run("C:\WINDOWS\system32\cmd.exe") WinWaitActive("C:\WINDOWS\system32\cmd.exe") Send($CMD) Sleep(1000) Send("{ENTER}") sleep(1000) MsgBox(0,"Press OK", "Press OK to continue") FileCopy("C:\Tiffchecker.txt", $sFileSelectFolder) Also, how do i close the command panel, when the program is finished? (usually its under 1 second, so after the send i just put a Sleep function there)
    • nacerbaaziz
      By nacerbaaziz
      Hello my friends
      I have an inquiry after your permission
      I found a function to get the special line commands for any operation
      It requires the name of the process to be searched
      I want to use it to know the process
      Is this possible with this function
      Here is the code
       
      Func commandLineGet($proc, $strComputer=".")
      dim $array[1]
      local $ArrayNumber
      local $oWMI = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $strComputer & "\root\cimv2")
      local $oProcessColl = $oWMI.ExecQuery("Select * from Win32_Process where Name= " & '"'& $Proc & '"')
      local $Process
      For $Process In $oProcessColl
      $Process = $Process.Commandline
          ReDim $Array[UBound($Array)+1]
      $ArrayNumber = UBound($Array)-1
      $array[$ArrayNumber] = $Process
      Next
      $ArrayNumber = UBound($Array)-1
      $array[0] = $ArrayNumber
      return $array
      EndFunc
    • BlazerV60
      By BlazerV60
      Hello all,
      I've written the code below which launches chrome in incognito mode and then proceeds to go to the autoit website.
      From my understanding, the Run() command is also supposed to output the PID number related to the application that got launched from the Run command.
      However when I run the below lines, it outputs a PID number that is different from the newly launched chrome browser's PID number, does anyone know why and possibly explain how I could retrieve the accurate PID number associated with the newly launched browser?
      Global $iPid = Run(@ComSpec & ' /c start chrome.exe https://www.autoitscript.com/forum/ -incognito' ,"", "") msgbox(0,"",$iPid) Thank you,
      Brian
    • mihaijulien
      By mihaijulien
      Hello,
      I compiled a script I made that takes a command line parameter (the version of a .msi installer) when launched. The script was compiled with the /console option. The script (.au3) works fine but the executable returns  the following error:  
      Error: array variable has incorrect number of subscripts or subscript dimension range exceeded  
    • Baboo85
      By Baboo85
      Hi all,
      I need to start a script that include:
      - admin privileges
      - multiple cmd commands
      - no bat, no exe, no tmp files created anywhere (especially in the user temp folder)
      In a bat file it would be simple, but users shouldn't see what commands I'm sending.
      Example of the script:
      echo off cls echo. echo I AM A TOOL echo. echo NOTE: echo - note 1 echo - note 2 echo - etc set USER1=0 set COMPUTER1=0 if /i %username% equ user.user ( set USER1=1 set COMPUTER1=1 ) if /i %username% equ another.user set USER1=1 if /i %computername% equ notebook set COMPUTER1=1 if %USER1% EQU 1 ( if %COMPUTER1% EQU 1 ( reg delete "HKLM\SOFTWARE\blablabla" /f ) else ( echo Computer not authorized. Contact assistance.) ) else ( echo User not authorized. Contact assistance.) echo. pause exit With the send("") is a disaster.
      I'm a noob here, so what can I do?
       
      EDIT: OR ELSE I explain the situation and what I need, so if there is a simple solution I can use that.
       
      SITUATION: our domain users have Users rights on the machine. Some of them need administrator rights.
      We create a local user with administrator rights, so that the users must insert username and password when asked to run something with administrator rights.
      We have an internal domain group policy that blocks EXE, BAT, COM, TMP files from the user local temp directory, for a security reason (malware). That also blocks most software installation.
      But some users are often out of office, away from workplace and in another country, they need a complete control on their computers.
       
      WHAT I NEED: I need to check the username and the computer name. If the username is the one with local administrator rights and the computer name is a computer that is qualified to temporary remove the policy, then I need to execute a REG DELETE command with administrator rights.
       
      I hope I explained myself.
       
      Thank you very much.
×