Sign in to follow this  
Followers 0

Browse for txt file containing computer name

8 posts in this topic

Trying to create a gui windows with a browse button to browse to a text file

Users will select the text file and then click on a RUN button, behind the scene autoit will read each line of the text file and append it to a command..

I would also like to know if there is a way to display the command prompt window within the guiwindow to show the user the progress of the commands...

Something like the attached file.. it's cheesy I know, it'll give an idea of what I'm trying to accomplish though


Share this post

Link to post
Share on other sites

_FileReadToArray perhaps? What is the text file content going to look like?

_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post

Link to post
Share on other sites

#4 ·  Posted (edited)

_FileReadToArray perhaps? What is the text file content going to look like?

The txt file will have a list of computers and I will use DSRM command, reading the computer names line by line and removing them from AD

I will also use camcmd to remove computers from out CA IT Client Manager server... so the content of the text file isn't my main focus

CMD to Remove Computers from AD

FOR /F "tokens=1,2* delims=," %%G IN (C:\remove.txt) DO dsrm %%G OU=Computers,DC=domainname,DC=suffix

CMD to Remove Computers from CA IT Client Manager

for /f "tokens=1,2* delims=," %%G IN (C:\remove.txt) DO cadsmcmd targetcomputer action=delete name=%%G

I'll put those commands in the tool

Here's a few AutoIt functions that will probably be used here.





Thanks, I'll take a look at those and see what I can find out..

Edited by Elephant007

Share this post

Link to post
Share on other sites

Some advertising :D

To remove computers from the AD you could use my Active Directory UDF. The UDF provides much better error handling and a lot of features which might be useful for other scripts you write.

My UDFs and Tutorials:


Active Directory (NEW 2017-04-18 - Version - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version - Download - General Help & Support

ADO - Wiki


Share this post

Link to post
Share on other sites

Here is something similar I wrote quickly for someone...

#include <GUIConstants.au3>
; Program name to run
Dim $_Program = "nrg2iso.exe"
; files to search for
Dim $_File = "*.nrg"
$GUI = GUICreate("My GUI", 350, 300)
$t_label = GUICtrlCreateLabel("Ready", 10, 50, 320, 20)
$d_label = GUICtrlCreateLabel("Counter", 10, 100, 320, 20)
$Button = GUICtrlCreateButton("GO", 135, 200, 80, 30)
While 1
 $msg = GUIGetMsg()
 If $msg = -3 Then Exit
 If $msg = $Button Then Runner()

Func Runner()
 Local $numID = 0, $TnumID = 0
 GUICtrlSetData($t_label, "Searching for " & $_File & "   ...Please wait...")
 RunWait(@ComSpec & ' /c ' & 'dir "' & @HomeDrive & $_File & '" /a :h /b /s' & ' > "' & @TempDir & '\dir.txt"', '', @SW_HIDE)

 $hFile = FileOpen(@TempDir & "\dir.txt", 0)
 ; Check if file opened for reading OK
 If $hFile = -1 Then
  MsgBox(0, "Error", "Unable to open file.")
 ; Read in lines of text until the EOF is reached
 While 1
  $sLine = FileReadLine($hFile)
  If @error = -1 Then ExitLoop
  If $sLine <> "" Then
   $numID = $numID + 1
   GUICtrlSetData($t_label, "Running - " & $sLine)
   If $numID >= $TnumID + 5 Then
    $TnumID = $numID
    GUICtrlSetData($d_label, " Files Ran: " & $TnumID)
   If FileExists($sLine) Then RunWait($_Program & " " & $sLine); Put your command here
   $msg = GUIGetMsg()
   If $msg = $GUI_EVENT_CLOSE Then ExitLoop
 GUICtrlSetData($t_label, "*** Complete ***")
EndFunc   ;==>Runner



Share this post

Link to post
Share on other sites

Here is a cool visual too..

#include <IE.au3>
Global $XT_oIE
XSkinConsole( "", 10, 10, 400, 300)
XSkinText("This is an example...")
XSkinText("Starting tasks...")
XSkinText() ; sends a blank line
XSkinText("... Clearing Screen")
XSkinText("CLR") ;Clears the XSkinConsole
$Text = StringSplit("Checking System...,System Located,Checking Folders...,Folders Found,Checking Files...,Files Found, Verifying Data....,....Complete",",")
$color = StringSplit("red,brown,orange,blue,yellow,green,gray,",",")
For $i = 1 To $Text[0] -1
    $msg = $i & @TAB & $Text[$i]
    XSkinText($msg, $color[$i])
XSkinText() ; send a blank line
XSkinText($Text[8], "Red", 6)

Func XSkinConsole($XT_GUI, $left, $top, $width, $height)
    $XT_oIE = _IECreateEmbedded()
    If Not IsHWnd($XT_GUI) Then
        $XT_GUI = GUICreate("", $width + (2 * $left), $height + (2 * $top))
    $XT_ActiveX = GUICtrlCreateObj($XT_oIE, $left, $top, $width, $height)
    _IENavigate($XT_oIE, "about:blank")
    Return $XT_ActiveX
EndFunc   ;==>XSkinConsole
Func XSkinText($msg = "", $color = "black", $size = "3")
    If $msg == "CLR"  Then Return _IEDocWriteHTML($XT_oIE, "")
    Return _IEDocWriteHTML($XT_oIE, _IEDocReadHTML($XT_oIE) & '<font color="' & $color & '" size=' & $size & '>' & $msg & '</font><br>')
EndFunc   ;==>XSkinText



Share this post

Link to post
Share on other sites

Here's something I've come up with, it's kinda dirty right now... it's going along the line of what I'm wanting to do (I haven't checked the new scripts that people put in here yet, I will thought)

The one thing I can't seem to figure out is how to get the CMD Prompt to show up inside the GUI window

I'm using a file named "Ping This.txt" the space is put in there on purpose for now and the file contains these simple lines

Ping This.txt

#include <GUIConstantsEx.au3>
#include <EditConstants.au3>
Opt('MustDeclareVars', 1)
DIM $InfoFile, $PINGIT, $1Cmd, $2Cmd, $Path
$1Cmd = 'CMD /C FOR /F "usebackq tokens=1,2* delims=," %G IN ("'
$2Cmd = '") DO ping %G'
Func Remover()
Local $Button_1, $Button_2, $msg
GUICreate("My GUI Button") ; will create a dialog box that when displayed is centered
Opt("GUICoordMode", 2)
$Path = GUICtrlCreateInput ("", 10, 15, 200, 20 )
$Button_1 = GUICtrlCreateButton("Browse", 10, 40, 100)
;~  GUICtrlCreateInput("",10,53,367,23)
$Button_2 = GUICtrlCreateButton("Button Test", 0, -1)
GUISetState()     ; will display an  dialog box with 2 button
; Run the GUI until the dialog is closed
While 1
  $msg = GUIGetMsg()
   Case $msg = $GUI_EVENT_CLOSE
   Case $msg = $Button_1
    $InfoFile = FileOpenDialog ("Browse", "C:\", "Text Documents (*.txt)")
    GUICtrlSetData($path, $InfoFile)
   Case $msg = $Button_2
;~   MsgBox ( 0, '', $1Cmd & $InfoFile & $2Cmd )
    $PINGIT = Run ( $1Cmd & $InfoFile & $2Cmd, '', @SW_SHOW )    ; Will demonstrate Button 2 being pressed
EndFunc   ;==>Remover

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