Computing Staff
  • 1

How To Make Dialog Box Interacting With Bat

  • 1

Hallow every one,

I have a question.

Is there any easy programing language or software to make a dialog box (GUI Window) which I can run from a bat file and receive one or more inputs (which I want users to provide) passed to that bat file?

I mean, for a batch programing usually we use (set /p <variable>=”<User prompt text string>”) syntax format to prompt a user to provide a input value what required, but I want to give a prompt to users through a dialog box (GUI Window) and receive the input value (wich a user have inputted) directly or indirectly (if not possible directly) passed to the corespondent running batch program.

Is that possible? if it is possible then i want to know in detailed about how to do it.

Can any one help me,

Please help me.

Share

3 Answers

  1. vis.basic or vbscript are probably what you’re wanting. here’s a vis basic program
    i wrote to put the clipboard contents into a text file. The “dialogue” is simply the
    path/filename where the user wants the clipboard content to go. (It eliminates having
    to use “notepad”, which i hate, and doing a filesave.)

    Attribute VB_Name = “clip”

    Sub main()
    ‘write clipboard into a file
    X = Clipboard.GetText
    c = InputBox(“CLIPBOARD CONTENT: ” + Chr(10) + X + Chr(10) + “file, [line#]: “)
    if ltrim(c)=”” then end
    p = InStr(c, ” “)
    If p > 0 Then
    Line = Mid(c, p + 1)
    c = Left(c, p – 1)
    Open “c:\windows\tempor~1\temp” For Output As #3
    Open c For Input As #1
    For i = 1 To Line
    If EOF(1) Then Exit For
    Line Input #1, k
    Print #3, k
    Next i
    Print #3, X
    Do While Not EOF(1)
    Line Input #1, k
    Print #3, k
    Loop
    Close
    Shell (“move /y c:\windows\tempor~1\temp ” + c), 2
    Else
    On Error GoTo 10
    Open c For Append As #1
    GoTo 20
    10 Resume 11
    11 Open c For Output As #1
    20 On Error GoTo 0
    Print #1, X
    Close #1
    End If
    End Sub
    ‘———————–
    vbscript uses the same command, “inputbox”, so you don’t have to aquire or
    posess a vis.basic platform to use the function, but has the slight disadvantage
    that it is not compiled so your batch file has to go like:
    cscript .\getdata.vbs
    and the “getdata” will probably have to write the data through an intermediate squibfile i believe (i’ve gotten real rusty from not using vbscript for awhile).

    • 0
  2. Sorry, for the mis-confusion, Lol! The program i gave was visual basic, not vbscript.
    Two different platforms…
    To do what you want, here is the vbscript “bare bones” version, vbscript first:
    ‘—- begin, getdata.vbs
    set outp=wscript.stdout
    c=inputbox(“what? “)
    outp.write(c)
    ‘———– end
    and here’s the batch that will invoke it:
    ::begin batch script dataget.bat
    @echo off & setlocal
    for /f “tokens=*” %%a in (‘cscript getdata.vbs’) do set x=%%a
    echo the returned value from the gui-box is: %x%
    ::—- end script
    This should work. It is the “absolute zero” of a working demo.
    Of course, make sure all the paths (to programs and scripts) are straight!

    • 0
  3. As i don’t know VB and VBSctipt for that region can you post the exact code what i have to have in the getdata.vbs file?

    Black_Blood,

    As nbrane posted, What should go in your VBS file is:

    set outp=wscript.stdout
    c=inputbox("what? ")
    outp.write(c)

    You will be able to call the to VBScript using this command in a batch file:

    for /f "tokens=*" %%a in ('cscript getdata.vbs') do set x=%%a

    Can I put a question here?

    • 0