Sign in to follow this  
Followers 0
Ferret

Display text in the CMD Window intitiating the script

2 posts in this topic

#1 ·  Posted (edited)

I have written a script that searches a directory specified and does a batch file renames based on certain specific criteria. I want a result message to appear that says something like '5 files processed.' in the console. I don't want a MsgBox or Tray Message.

Here's an example of what I'm looking for:

C:\>BatchRename C:\TestFiles

5 Files processed successfully.

C:\>

I did a search and couldn't find any information on doing this. Can it be done?

Many thanks!

Edited by Ferret

Murphy lives here.My website, if you care: HIPAA Information Security Resources

Share this post


Link to post
Share on other sites



Compile this and run the exe in a DOS box:

Global $aResult, $hConsole

if not _API_AttachConsole() then
  MsgBox(0, "Error", "AttachConsole failed")
  Exit
endif

$hConsole = _API_GetStdHandle()
if $hConsole = -1 then
  MsgBox(0, "Error", "GetStdHandle failed")
  Exit
endif

if not _API_WriteConsole($hConsole, "Hello World" & @CRLF) then
  MsgBox(0, "Error", "WriteConsole Failed")
endif

Func _API_AttachConsole()
  $aResult = DllCall("Kernel32.dll", "int", "AttachConsole", "dword", -1)
  Return $aResult[0] <> 0
EndFunc

Func _API_GetStdHandle()
  $aResult = DllCall("Kernel32.dll", "int", "GetStdHandle", "int", -11)
  Return $aResult[0]
EndFunc

Func _API_WriteConsole($hConsole, $sText)
  $aResult  = DllCall("Kernel32.dll", "int", "WriteConsole", "int", $hConsole, "str", $sText, "int", StringLen($sText), "int_ptr", 0, "int", 0)
  Return $aResult[0] <> 0
EndFunc

Auto3Lib: A library of over 1200 functions for AutoIt

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
Sign in to follow this  
Followers 0