Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

run windows command line statement from java

 
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.
 
Marshal
Posts: 64666
225
  • 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!