• Post Reply Bookmark Topic Watch Topic
  • New Topic

run windows command line statement from java

 
Amarjeet Anand
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
i wanted to build a simple java desktop app where on button click event, some lines of code execute in windows Command Prompt and display the output in a textbox.
I have to run commands as below in administrative privilage and display the output message in a textbox.

netsh wlan set hostednetwork mode=allow ssid=NAME key=PASSWORDis@HARDTOBREAK;
netsh wlan start hostednetwork


I have saved this code in a start.bat file.
i have tried




i have also tried ,,,, but it also doesn't work.


 
Amarjeet Anand
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have tried the code below. It runs correctly and gives output also.


But command doesn't execute and noting comes to output when i change the command from dir to netsh wlan show hostednetwork because this command requires administrative privilage.
 
Campbell Ritchie
Marshal
Posts: 52565
119
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don&aps;t even think of using processes until ylu have read the classic article which you can find by searching When Runtime.exec won't by Michael Daconta.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!