• 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

runtime,exec()

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi to you all,
I have a bit of a puzzle here. I'm trying to execute a "runas.exe" command to grantAuthority for a directory somewhere in my network. To pipe the password in runas I use "sanur". From a windows cmd.exe this all work fine. The syntax is something like this:
C:\temp\runas /user:aUser "C:\temp\xcacls \\networkplace\c\temp\somedirectory /g superUser:c /e" | C:\temp\sanur KLmn500
runas.exe is standard windows. sanur is shareware. xcacls.exe can be found in de windows resource kit.
The same put in to runtime.exec{"cmd.exe","/c","C:\temp\runas /user:aUser \"C:\\temp\\xcacls \\\\networkplace\\c\\temp\\somedirectory /g superUser:c /e\" | C:\\temp\\sanur KLmn500"};
The process returns ExitValue: 1 and does nothing.
Probably the "|" is the little bugger. Anyone ???
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yup, piping is no good. Look at the process object you get back from exec. You can hook up to the stdout and errout streams. For many commands you must read both streams to end or the whole thing hangs up. It may be useful to start a couple threads to read these streams and join() everything back together when the command finishes. If that made no sense, jump over to the threads forum and ask what is that crazy guy talking about?
 
Nothing? Or something? Like this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic