我有一个批处理文件,它是一个非常简单的程序,它启动网站,迷你网络浏览器类型体验,打开程序的命令等。我如何为这个或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命令和用户输入等。
答案 0 :(得分:3)
图形命令在直接批处理文件中不可用。我建议你看一下vbscript或powershell
有很多指南 - 这是vbscript的帮助文件。是的,它会有所不同。 Echo Hello World将成为msgbox(“Hello World”),输入看起来像inputbox(“你叫什么名字?”)(在一个非常基础的层面上)
没有自动转换,除非你有Visual Studio,没有免费的集成开发人员,但notepad++似乎是首选的编辑器,因为它的语法高亮
来自here,带有菜单的示例脚本
'-----------------------------------------------------------------
' 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
'*****************************************************************
'---------------------
'***************************************