fopetesl

Run(Wait) failures

8 posts in this topic

#1 ·  Posted

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



#2 ·  Posted

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")
1 person likes this

Share this post


Link to post
Share on other sites

#3 ·  Posted

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

#4 ·  Posted (edited)

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

#6 ·  Posted

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

#7 ·  Posted

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

    • 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.
    • ur
      By ur
      How to enable file sharing for all public,private,work,home networks.
      I mean programatically using AutoIT.
    • LegitStack
      By LegitStack
      Is there a way to execute the text inside a variable is if it was part of the script?
      In this example I'd like to get a message box pop up but I don't: 
      ;testme.au3   local $var = 'msgbox(64,"hello","world")'   $var is there a command that can be used like maybe 'Exec' or 'Execute' or something?
        local $var = 'msgbox(64,"hello","world")'   Execute $var  
    • GHOSTYAIRO
      By GHOSTYAIRO
      I have a script that changes the path to a file inside a program, the program itself is a pain in the @## I have no idea what language was coded with but the autoit windows info doesn't even recognize 90% of the gui.
      Anyway I need to send the new path which is inside the local app folder, I'am using a variable to hold it. but the User folder has the "#" character in the name and for some reason autoit won't send it, it just stops right before the "#" and doesn't send the rest of the path either. it doesn't return any error it just stops sending, the rest of the script is still executed.
      I'm using the Send() command to send the keys.
      Here's what I have:
      $dbPath = @UserProfileDir & '\AppData\Local\database\db.mdb' Run("Notepad.exe") WinWait("Untitled - Notepad") WinActivate("Untitled - Notepad") Send($dbPath) Now in my case @UserProfileDir is called Tech #1 so what I'm expecting Send() to type is 
      C:\Users\Tech #1\AppData\Local\database\db.mdb But what I'm actually getting is just
      C:\Users\Tech notice there's the space after the "h", so it is stopping exactly before the "#"
      Now you might say why I need to use a var instead of just sending the actual string path, well I don't want to do a separate script for all the computers and guess what, they all have the "#" in their user names, yes Tech #2, Tech #3, Tech #4, Front #1, Front #2, Shipping #1... and so on.
      BTW on a side note, I noticed the autoit macros page shows the  @LocalAppDataDir  as a viable macro but it's not working for me, it return "unknown macro", I had to use @UserProfileDir and and the \AppData\Local, because the @AppDataDir takes me to Roaming anyway. 
      While I was writing that last paragraph, I said to my self, yeah why not just copy and paste the script and compile as many as I need but use plain text instead of a variable, so I went back and did just
      Run("Notepad.exe") WinWait("Untitled - Notepad") WinActivate("Untitled - Notepad") Send("C:\Users\Tech #1\AppData\Local\database\db.mdb") Guess what!!!, yeah you guessed it, it did the same thing, it stopped right before the "#".
      I know most will be thinking, nah he's crazy why would that happen, go ahead and try for yourself, I'll wait... (because I tried in 3 different computers).
      Ok so you are back, did it work for you? can you explain why it's not working for me, or it didn't work for you as well and you are as clueless as me?
      And while I was writing all this my brain was working on the background and I just had an idea to work around it, I'll be right back...
      $dbPath = @UserProfileDir & '\AppData\Local\DiGital WorkShop\POS Panic\PM229.mdb' Run("Notepad.exe") WinWait("Untitled - Notepad") WinActivate("Untitled - Notepad") ClipPut($dbPath) Send("{CTRLDOWN}v{CTRLUP}") Ok so this actually works for me and I can finally breath, but I'm still annoyed by the fact that autoit won't Send("#1") or Send("#2"), yes I actually tried just sending that and nothing, and I just realize what is doing, (this lecture will annoy most people lol), by sending #1, #2, #3 ans so on it is activating windows in the same order they are pinned in the taskbar, I had autoit first, then chrome, the my mail app, so every time I use Send("#1") activates autoit, which I didn't noticed at all because well I was using autoit, but then when I Send("#2") and it brought chrome to the front, then Send("#3") and activated my mail app (which btw was minimized).
      What in the world is happening some please explain me this behavior and please tell me how would you workaround the issue.
      Thanks.