Getting input data after execution of batch file.


  1. Posts : 6
    Windows 8 ultimate 32 bit
       #1

    Getting input data after execution of batch file.


    My batch file code is like this:


    @echo off
    C:\Windows\System32\netsh.exe wlan set hostednetwor mode=allow ssid=User_Name key=password eyUsage=persistent


    In this code the "User_name" and "password" fields I want the input from the user after running the batch file. How do I make it ??? Please help. And also suggest me modifications in this code if any.
      My Computer


  2. Posts : 1,519
    Windows 7 Ultimate 64-bit, Windows 8.1 64-bit, Mac OS X 10.10, Linux Mint 17, Windows 10 Pro TP
       #2

    No suggestion for the input part but generally a batch file is completed when it finishes the last line and closes. If I don't want the Command Prompt window to close until I have read it I put Pause as the last element, won't go beyond that until I hit Enter to let it complete.
      My Computer


  3. Posts : 6,285
    Windows 10 Pro X64
       #3

    Request the input before running netsh:

    Code:
    @echo off
    set /p UserName= Enter User name: 
    set /p Password= Enter Password: 
    echo Username is %UserName% and Password is %Password%
    
    C:\Windows\System32\netsh.exe wlan set hostednetwor mode=allow ssid=%UserName% key=%Password% eyUsage=persistent
    For readability, make sure there is a space after name: and Password:.
      My Computer


  4. Posts : 2,468
    Windows 7 Ultimate x64
       #4

    Typically console programs request additional info on the command line and use those or report an error if they were not provided. Try something like this:

    Code:
    @echo off
    if "%1"=="" goto ShowUsage
    if "%2"=="" goto ShowUsage
    C:\Windows\System32\netsh.exe wlan set hostednetwor mode=allow ssid=%1 key=%1 keyUsage=persistent
    goto End
    
    :goto ShowUsage
    echo You must specify username and password.
    Example: SetWlan MyUser MyPassword
    
    :End
    Here assuming this file is named SetWlan.
    Then invoke it like any other command line tool:

    Code:
    SetWlan MyUser MyPassword
    Providing the wrong parameters will print the correct usage instructions.
      My Computer


  5. Posts : 6
    Windows 8 ultimate 32 bit
    Thread Starter
       #5

    Thanks to everyone


    Thanks for your valuable help. I got the solution which I want with your help. Thanks Once Again.
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 19:58.
Find Us