• Post Reply Bookmark Topic Watch Topic
  • New Topic

runtime,exec()  RSS feed

 
Francis Schep
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • 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 ???
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • 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?
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!