Getting input data after execution of batch file.

swapnil007

New member
Local time
2:32 AM
Messages
6
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

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Lenovo
OS
Windows 8 ultimate 32 bit
Memory
4 GB
Graphics Card(s)
1 GB
Hard Drives
500 GB
Antivirus
windows defender
Browser
chrome & firfox
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

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Customs, Dell, Gateway, HP, Toshiba, Acer, ASUS
OS
Windows 7 Ultimate 64-bit, Windows 8.1 64-bit, Mac OS X 10.10, Linux Mint 17, Windows 10 Pro TP
Keyboard
Microsoft
Mouse
Microsoft
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

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Lenovo IdeaCenter 450
OS
Windows 10 Pro X64
CPU
Intel Quad Core i7-4770 @ 3.4Ghz
Memory
16.0GB PC3-12800 DDR3 SDRAM 1600 MHz
Graphics Card(s)
Intel Integrated HD Graphics
Sound Card
Realtek HD Audio
Monitor(s) Displays
HP 22" LCD
Screen Resolution
1680 x 1050
Hard Drives
250GB Samsung EVO SATA-3 SSD
2TB Seagate ST2000DM001 SATA-2
1.5TB Seagate ST3150041AS SATA
Keyboard
Dell USB
Mouse
Lenovo USB
Internet Speed
Cable via Road Runner 3MB Upload, 30MB Download
Antivirus
Windows Defender, MBAM Pro, MBAE
Browser
Seamonkey
Other Info
UEFI/GPT
PLDS DVD-RW DH16AERSH
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

Computer type
Laptop
Computer Manufacturer/Model Number
Toshiba Sattelite A665-S6092
OS
Windows 7 Ultimate x64
CPU
Intel Core i7-740QM
Memory
8 GB DDR3
Graphics Card(s)
NVIDIA GeForce 330GT
Screen Resolution
1366x768
Hard Drives
Samsung 840 SSD 500GB
1TB USB3 external HD
Cooling
Coolermaster Notepal U3 notebook cooling pad
Internet Speed
3mbps ASDL
Antivirus
ClamWin 0.98.7
Browser
Opera 12.17 x86 (main), Firefox 38 (sec), IE11 (last resort)
Thanks to everyone

Thanks for your valuable help. I got the solution which I want with your help. Thanks Once Again.:D:thumbsup:
 

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Lenovo
OS
Windows 8 ultimate 32 bit
Memory
4 GB
Graphics Card(s)
1 GB
Hard Drives
500 GB
Antivirus
windows defender
Browser
chrome & firfox
Back
Top