3

我有一个批处理文件,它是一个非常简单的程序,可以启动网站、迷你网络浏览器类型的体验、打开程序的命令等。我怎样才能为此或 GUI 制作界面?无需完全手动更改我的代码。这是我的代码的示例:

: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 

当然还有更多的代码,但这是我的程序的编写方式,还有一些 START 命令和用户输入等。

4

1 回答 1

3

图形命令在直接批处理文件中不可用。我建议你看看 vbscript 或 powershell

有很多指南 - 这是vbscript的帮助文件。是的,它会有所不同。Echo Hello World 会变成 msgbox("Hello World") 并且输入看起来像 inputbox("What is your name?") (在非常基本的层面上)

没有自动转换,除非你有 Visual Studio,否则没有免费的集成开发人员,但notepad++似乎是首选编辑器,因为它的语法突出显示

这里,一个带有菜单的示例脚本

'-----------------------------------------------------------------
' 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
'*****************************************************************
'---------------------

'***************************************
于 2012-09-19T19:42:54.970 回答