Jump to content

Recommended Posts

Posted

how about adding the call to utility.exe as the last command of the batch file?

Signature - my forum contributions:

  Reveal hidden contents

 

Posted

Well, basically FileName.bat sets the ground for a lot of similar utilities. I can assure that you can't count that number on your fingers. Moreover, it is just not this, I made this sometime ago

I've come quite far from that code with bugs and that tool is fully functioning now. Because I'm not a coding guy, for a moment I thought that it was cool and I had overwhelmed myself. So I thought, I'll automate everything that I do manually and what I'm asking you is just the first step to it. If I can get to run this, I can run anything.

Posted

let's go back to your script at post #19 then. what exactly is not working? for example, what output are you receiving, and what are you expecting to receive? what error messages do you get?

Signature - my forum contributions:

  Reveal hidden contents

 

Posted

Like you said, once the FileName.bat is run once, its work doesn't exist when utility.exe is called. The output that I am receiving is the same as what I get on command prompt if utility.exe is run without first running FileName.bat. When utility.exe is run without FileName.bat, it produces an error which roughly translates to something like the connection could not be established. This utility.exe does a similar job like "net user". It returns the users running an application. FileName.bat establishes the connections and does some jobs with the environment and stuff. So all in all, I cannot run utility.exe unless FileName.bat is run first.

Posted (edited)

it all goes back to the need to maintain a single DOS session. if you do not want to alter existing batch file, then create a "parent" batch file that will call the existing bat and the utility, like this (not tested!):

Global $sCallerScript = @ScriptDir & '\mybat.bat'
FileWriteLine($sCallerScript, 'call \\server\share\path\filename.bat')
FileWriteLine($sCallerScript, 'c:\some\path\folder\utility.exe utility -opt=1 -opt=2 -opt=3')
$DOS = Run($sCallerScript, "", @SW_MAXIMIZE, $STDERR_CHILD + $STDOUT_CHILD)
ProcessWaitClose($DOS)
$Message = StdoutRead($DOS, True)

 

Edited by orbs

Signature - my forum contributions:

  Reveal hidden contents

 

Posted (edited)

@orbs That worked! You got that right about maintaining a single DOS session. I had to add a few lines to set the environment variables as previously defined. Also, the output contains everything that is generated on a command prompt console which includes the setting of variables, running the batch, running the tool and then the output. I just need the output. Can you help me with that?

EDIT: Will the .exe work the same with @ScriptDir?

Edited by pranaynanda
Posted
  On 5/10/2016 at 5:58 AM, pranaynanda said:

I just need the output.

Expand  

then simply ignore anything else.

if you find it hard to detect the first output line of the utility, then add an indicator in the caller script just before calling the utility, something like this:

Global $sCallerScript = @ScriptDir & '\mybat.bat'
FileWriteLine($sCallerScript, 'call \\server\share\path\filename.bat')
FileWriteLine($sCallerScript, 'echo THIS IS WHERE THE OUTPUT BEGINS')
FileWriteLine($sCallerScript, 'c:\some\path\folder\utility.exe utility -opt=1 -opt=2 -opt=3')
$DOS = Run($sCallerScript, "", @SW_MAXIMIZE, $STDERR_CHILD + $STDOUT_CHILD)
ProcessWaitClose($DOS)
$Message = StdoutRead($DOS, True)

so when you read the entire output, ignore anything before the line saying THIS IS WHERE THE OUTPUT BEGINS.

 

  On 5/10/2016 at 5:58 AM, pranaynanda said:

Will the .exe work the same with @ScriptDir?

Expand  

yes. all macros are computed at runtime no matter if the script is compiled or not. the only exceptions are @AutoItExe and @Compiled. see the help file (AutoIt > Macro Reference) for more info.

Signature - my forum contributions:

  Reveal hidden contents

 

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...