
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Running CMD as Administrator in Windows is not working in TOSBD 8
I am trying to develop a tJava component that will run a cmd.exe command as administrator. In normal Java parlance you can do this with
Runtime rt = Runtime.getRuntime();
rt.exec("runas /profile /user:Administrator \"cmd.exe /c start \"\" cmd echo HELLO > myOutput.txt \"");
However, I cannot get Talend to run this with any results.
It only works when I do not have the runas elements. Even then the data doesn't pipe to the file.
I have to run a psexec command as a administator and so far the only options I see are 1) use a tSystem but that doesn't have a run as administrator option 2) use a tJava with the code above that doesn't run when runas is used.
The example above is the simple one I can't get to work, these are more like the actual codes that will have to work
Runtime rt = Runtime.getRuntime();
rt.exec("runas /profile /user:Administrator /savecred \"cmd.exe /c start \"\" \"psexec \\127.0.0.1 -u DOMAIN\\ADMIN_ACCT -p \"1234567\" C:\\Path_To_My_EXE\\My.exe \"EXE_PARAM1\" \"EXE_PARAM2\" \"EXE_PARAM3\" > C:\\Path_to_my_output\\psexecOut.txt\"");
Runtime rt = Runtime.getRuntime();
rt.exec("runas /profile /user:Administrator /savecred \"cmd.exe /c start \"\" \"psexec \\127.0.0.1 -u DOMAIN\\ADMIN_ACCT -p \"1234567\" C:\\Path_To_My_EXE\\My.exe \""+context.EXE_PARAM1+"\" \""+context.EXE_PARAM2+"\" \""+context.EXE_PARAM3+"\" > C:\\Path_to_my_output\\psexecOut.txt\"");

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
To help it would be great to know what went wrong. BTW an option "Run as administrator" is not possible in tSystem because this would destroy the platform independency.
