Jump to content

Run batch file on a seperate window from consolewrite?


Recommended Posts

Hi everyone.

I'm currently working a program that constantly prints out log files through "consolewrite" and the "#AutoIt3Wrapper_Change2CUI=y" wrapper.

Part of this program requires me to run a batch script.

My issue is the batch script launches from the same window as consolewrite. I need the batch file to be launched through a different window as currently this causes an issue with the logs (which need to be very precise) but also causes the batch file to produce some funny behavior...

Does anyone know how I can force the file to run on a second DOS window?

Thanks in advance!!!

 

Edit: Im using the "run" command if that helps. I tried "shellexecute" but that seemed to not launch the batch scripts at all.

Edited by fosil
Link to comment
Share on other sites

Instead of using ConsoleWrite to create the log information, why don't you just write it to a file, and then it won't need to run as a CUI program.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

10 minutes ago, BrewManNH said:

Instead of using ConsoleWrite to create the log information, why don't you just write it to a file, and then it won't need to run as a CUI program.

 

I have to do both. The logs get displayed in real time on the console as well as a text file. Unfortunately I can't change that part.

Link to comment
Share on other sites

Sure you can, use an edit control to display the live content.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

1 minute ago, BrewManNH said:

Sure you can, use an edit control to display the live content.

I'm not quite sure what you mean by that? Can you give me an example?

I'm not entirely sure If I can incorporate it in my situation because that part was written by someone else and I rather leave it alone, but if itl fix this issue im open to it :)

Link to comment
Share on other sites

Show me your script and I'll show you how to modify it.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

This is the function responsible for creating the logs:

 

Func Write_log($aString)

    local $logfile = "D:\Logs\logfile.txt"

    local $openlogfile = FileOpen($logfile)

    If FileExists($logfile) = 0 Then
        _FileCreate($logfile)
    EndIf

    If StringLen($aString) = 0 Then
        FileWriteLine($logfile,@CRLF)
        ConsoleWrite(@CRLF)

    Else
        FileWriteLine($logfile,_Now() & ": " & $aString & @CRLF)
        ConsoleWrite(_Now() & ": " & $aString & @CRLF)

    EndIf

    FileClose($openlogfile)

EndFunc

 

Link to comment
Share on other sites

Here's one way of doing it.

; somewhere at the start of your script you create a GUI and put an Edit control in it.

Func Write_log($aString)

    local $logfile = "D:\Logs\logfile.txt"

    local $openlogfile = FileOpen($logfile)

    If FileExists($logfile) = 0 Then
        _FileCreate($logfile)
    EndIf

    If StringLen($aString) = 0 Then
        FileWriteLine($logfile,@CRLF)
        GUICtrlSetData($hSomeEditControlID, @CRLF, 1)
    Else
        FileWriteLine($logfile,_Now() & ": " & $aString & @CRLF)
        GUICtrlSetData($hSomeEditControlID, _Now() & ": " & $aString & @CRLF, 1)
    EndIf

    FileClose($openlogfile)

EndFunc

The number 1 at the end of the GUICtrlSetData is there just so that it's not an empty string, so that it will append your text to the end of the Edit control instead of overwrite its contents.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
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
 Share

×
×
  • Create New...