choward

Adding a GUI to a batchfile

24 posts in this topic

Hi, I have a batch file that installs some programs and changes some registry keys and then asks if everything installed correctly. I want to make a nice GUI for this, I've been looking at .hta files but these all involve pressing a button in a nice GUI that then opens the batch file like normal, basically I want it to embed the batch file in the GUI.

Share this post


Link to post
Share on other sites



Basically how do I wrap my batch file in a nice GUI?

Share this post


Link to post
Share on other sites

Would that run the batch file in a nice GUI so I can see the output of it in the GUI instead of CMD?

Share this post


Link to post
Share on other sites

It is all possible, Not sure what your batch files does, but you probably don;t even need the batch file but can use AutoIt3 syntax for everything.
You are able to shell CUI programs and capture their STDOUT / STDERRR output.

Jos

 


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

It basically sets up a PC after a brand new install of Windows. So installs programs and edits the registry. So it needs to be able to run without installing anything.

Share this post


Link to post
Share on other sites

Just a question, instead of making a GUI for your batch file, make a program that does the same thing as your batch file?

Share this post


Link to post
Share on other sites

Can do, but I don't know any languages.

Share this post


Link to post
Share on other sites

I can show you the batch file if that would help?

Share this post


Link to post
Share on other sites

choward,

It most certainly would - see here how to do it.

M23

 


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
@ECHO off
COLOR 1F
:START
@ECHO Install BRM OEM ...
REG ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\OEMInformation /v Logo /t REG_SZ /d "C:\Windows\BRM Computers\oem.bmp" /reg:64 /f
REG ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\OEMInformation /v Manufacturer /t REG_SZ /d "BRM Computers" /reg:64 /f
REG ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\OEMInformation /v SupportHours /t REG_SZ /d "Mon-Fri 9am-5pm - Sat 9am-4pm" /reg:64 /f
REG ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\OEMInformation /v SupportPhone /t REG_SZ /d "08712 244129" /reg:64 /f
REG ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\OEMInformation /v SupportURL /t REG_SZ /d "hhtp://www.brmcomputers.co.uk" /reg:64 /f
MD "C:\Windows\BRM Computers\"
%EXTD% /unzip oem.zip "C:\Windows\BRM Computers\"
@ECHO Installing Chocolatey ...
@powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin
@ECHO Installing Google Chrome ...
CHOCO install googlechrome -y
@ECHO Installing Firefox ...
CHOCO install firefox -y
@ECHO Installing VLC Media Player ...
CHOCO install vlc -y
@ECHO Installing 7zip ...
CHOCO install 7zip -y
@ECHO Installing Flash Player ...
CHOCO install flashplayerplugin -y
@ECHO Installing Java ...
CHOCO install javaruntime -y
@ECHO Installing Adobe Reader ...
CHOCO install adobereader -y
@ECHO Installing Kaspersky Internet Security ...
CHOCO install kisbrm -version 16.0.0.614 -y
@ECHO Installing Apache OpenOffice ...
CHOCO install openoffice -y
@ECHO Installing TeamViewer ...
CHOCO install teamviewer -y
@ECHO Settings taskbar icons ...
DEL /F /S /Q /A "%AppData%\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar\*"
REG DELETE HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Taskband /F
TASKKILL /f /im explorer.exe
START explorer.exe
TIMEOUT 5 /NOBREAK
DEL /F /S /Q /A "%AppData%\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar\*"
REG DELETE HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Taskband /F
TASKKILL /f /im explorer.exe
START explorer.exe
TIMEOUT 5 /NOBREAK
SYSPIN "C:\Program Files\Mozilla Firefox\firefox.exe" c:5386
SYSPIN "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" c:5386
SYSPIN "C:\Windows\explorer.exe" c:5386
:QUESTION
SET /p ANSWER=Did everything install correctly? (Y/N):
IF /i %ANSWER% == Y GOTO YES
IF /i %ANSWER% == y GOTO YES
IF /i %ANSWER% == Yes GOTO YES
IF /i %ANSWER% == yes GOTO YES
IF /i %ANSWER% == N GOTO NO
IF /i %ANSWER% == n GOTO NO
IF /i %ANSWER% == No GOTO NO
IF /i %ANSWER% == no GOTO NO
GOTO QUESTION
:YES
EXIT
:NO
GOTO START
GOTO QUESTION

 

Share this post


Link to post
Share on other sites

Just open SciTE and open/create a file somename.au3.
Press F1 and start looking for the following commands (sequence of your batchfile):

  • DirCreate
  • RegWrite()
  • DirCreate()
  • ShellExecuteWait() or RunWait() to run the unzip command you use and possibly the powershell command
  • same for subsequent installs
  • etc

Just look at the GUI section of the helpfile to find examples of GuiCtreate and all its possible controls.
Post questions when you have tried something and hitting a brick wall. :)

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Could you write me an example of some of the commands? Is it literary just the command I change?

Share this post


Link to post
Share on other sites

I am not in the "write a script" business, but have no issue helping people that are trying/learning themselves. ;)
You have been given some pointers how to start and I am wondering whether you have started with those first steps yet.

Jos
 


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

I have started to rewrite it, although I'm not sure how to add in files like the zips.

Share this post


Link to post
Share on other sites

#17 ·  Posted (edited)

41 minutes ago, choward said:

I'm not sure how to add in files like the zips.

FileInstall() ?

Do you really want to add the installers to the Script as you now also shell them from somewhere? 

Jos

Edited by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

I want to compile them into the exe so it's only 1 file I have to copy over each time. Also I couldn't get ShellExecuteWait() or RunWait() to work. I really have no idea what I'm doing.

Share this post


Link to post
Share on other sites
DirCreate("C:\Windows\BRM Computers\")
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\OEMInformation", "Logo", "REG_SZ", "C:\Windows\BRM Computers\oem.bmp")
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\OEMInformation", "Manufacturer", "REG_SZ", "BRM Computers")
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\OEMInformation", "SupportHours", "REG_SZ", "Mon-Fri 9am-5pm - Sat 9am-4pm")
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\OEMInformation", "SupportPhone", "REG_SZ", "08712 244129")
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\OEMInformation", "SupportURL", "REG_SZ", "http://www.brmcomputers.co.uk")
Example()
Func Example()
    Local $iReturn = RunWait(@ComSpec & " /c " & "@powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin")
    MsgBox($MB_SYSTEMMODAL, "", "The return code from CMD was: " & $iReturn)
EndFunc

 

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