Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GUI for batch file? [duplicate]

I have a batch file, and it is a very simple program that launches website, a mini- web browser type experience, with commands that open programs, etc. How can i make an interface for this or a GUI? Without having to compleltey manually change my code. Here is an example of what my code is like:

:start
@echo off
COLOR 1E
cls
echo Welcome to Wannow Dashboard.  This is the main page.
echo Type in the number to be redirected to your desired location.
echo 1. Useful Websites
echo 2. Programs     
echo Wannow Dashboard created by Brad Wannow

set/p var1=
if %var1% == 1 goto Websites
if %var1% == 2 goto program
pause
exit

:websites
COLOR 1E
cls
echo Welcome to Wannow Dashboard: Websites. Select a command, type in number to be redirected.
echo 1. www.Pandora.com
echo 2. www.Google.com
echo 3. Aventa Blackboard
echo 4. Other
@echo OFF 

@echo %time% 
ping -n 1 -w 1 127.0.0.1 1>nul        
echo Wannow Dashboard 

Of course there is much more code, but this is the way my program is written, with also some START commands and user inputs, etc.

like image 771
user1683444 Avatar asked Apr 29 '26 15:04

user1683444


1 Answers

graphical commands are not available in straight batch files. I would suggest you look at vbscript or powershell

there are many guides - this is the help file for vbscript. yes it will be different. Echo Hello World would become msgbox("Hello World") and an input would look like inputbox("What is your name?") (at a very basic level)

there is no automatic conversion, and unless you have Visual Studio, no free integrated developer, but notepad++ seems to be the preferred editor because of its syntax highlighting

from here, an example script with a menu

'-----------------------------------------------------------------
' Name: Menu Template Script
' By: Harvey Colwell
' CopyRight: (c) Jul 2000, All Rights Reserved!
'
'*****************************************************************
Option Explicit

Dim oFS, oWS, oWN

Set oWS = WScript.CreateObject("WScript.Shell")
Set oWN = WScript.CreateObject("WScript.Network")
Set oFS = WScript.CreateObject("Scripting.FileSystemObject")

'----------
' Script SetUp
'----------

'----------
' Main
'----------
Select Case InputBox ( _
"Enter menu item number then Click Ok. . ." & vbCrlf & vbCrlf & _
" [1] Item 1" & vbCrlf & _
" [2] Item 2" & vbCrlf & _
" [3] Item 3" & vbCrlf & _
" [4] Item 4", _
"Main Menu")

Case "1"
Call sub1()
Case "2"
Call sub2()
Case "3"
Call sub3()
Case "4"
Call sub4()
Case Else
WScript.Echo "You entered an invalid menu choice!"

End Select

'----------
' Clean Up
'----------

Call CleanUp

'-----------------------------------------------------------------
' Subroutines
'*****************************************************************

'---------------------
Sub CleanUp()
Set oWS = Nothing
Set oWN = Nothing
Set oFS = Nothing
WScript.Quit
End Sub

'---------------------
Sub sub1()
WScript.Echo "You selected Menu Item 1"
End Sub

'---------------------
Sub sub2()
WScript.Echo "You selected Menu Item 2"
End Sub

'---------------------
Sub sub3()
WScript.Echo "You selected Menu Item 3"
End Sub

'---------------------
Sub sub4()
WScript.Echo "You selected Menu Item 4"
End Sub

'-----------------------------------------------------------------
' Functions
'*****************************************************************
'---------------------

'***************************************
like image 178
SeanC Avatar answered May 01 '26 09:05

SeanC