orbs Posted May 9, 2016 Posted May 9, 2016 how about adding the call to utility.exe as the last command of the batch file? Signature - my forum contributions: Spoiler UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration - literal description of the difference between given dates Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff
pranaynanda Posted May 9, 2016 Author Posted May 9, 2016 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.
orbs Posted May 9, 2016 Posted May 9, 2016 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: Spoiler UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration - literal description of the difference between given dates Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff
pranaynanda Posted May 9, 2016 Author Posted May 9, 2016 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.
orbs Posted May 9, 2016 Posted May 9, 2016 (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 May 9, 2016 by orbs Synapsee and pranaynanda 2 Signature - my forum contributions: Spoiler UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration - literal description of the difference between given dates Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff
pranaynanda Posted May 10, 2016 Author Posted May 10, 2016 (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 May 10, 2016 by pranaynanda
orbs Posted May 10, 2016 Posted May 10, 2016 4 hours ago, pranaynanda said: I just need the output. 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. 4 hours ago, pranaynanda said: Will the .exe work the same with @ScriptDir? 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: Spoiler UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration - literal description of the difference between given dates Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now