• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Executing Windows Script from java

 
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi all,

i am trying to execute the adminscript for Starting/Stoping the Web Server IIS5.0 in windows 2000.

The following is the code
--------------------------------------------------------------------
Process r = ob.exec("c:/inetpub/adminscripts/startweb.vbs -a 1,2 -c globalv");
r.waitFor();
--------------------------------------------------------------------

i get the exception as below.
---------------------------------------------------------------
Exception in thread "main" java.io.IOException: CreateProcess: c:\inetpub\admins
cripts\startweb.vbs -a 1,2 -c globalv error=193
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(Unknown Source)
at java.lang.ProcessImpl.start(Unknown Source)
at java.lang.ProcessBuilder.start(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at ScriptExec.main(ScriptExec.java:18)
---------------------------------------------------------------
Pls help in solving this problem.

Pls move this to appropriate forum because i am not sure where to post.

Regards
Roshini.S
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A .vbs file isn't an executable, so you can't execute it directly with exec(). I believe you have to exec() CMD.EXE and pass this whole command line as an argument; i.e., "CMD /C <everything else>".
 
Roshini Sridharan
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I got it correctly.

Thank you so much sir for ur valuable guidance.



Regards
Roshini.S
reply
    Bookmark Topic Watch Topic
  • New Topic