I need to run the following command using java:
"wmic product where description='" + someProgram + "' uninstall"
This CMD works only when running as Administrator.
This program will run in several machines with different passwords, so I can't insert passwords in my program.
How can I run it as Admin, without running the whole program as administrator?
Edit:
This program runs on a local Windows machine (no dealing with remotes)
I believe it is possible in Unix for your Admin to write to write a Shell Script which runs with the priveleges of another User-ID & which members of the Group (or Anyone) may start.
See: Setuid & chmod
If you are looking for a remote solution (where the Java makes say an SSH connection to the remote and then runs the command), then can't you configure the process running on those machines - providing the SSH server - so it runs commands as an appropriately privileged user?
AND/OR find a localgroup that gives the permissions you need?
Related
We are in the corporate windows AD network, When we try to execute the below SSH command in CMD, it works fine,
ssh -o GSSAPIAuthentication=yes userid#servermachine.xyz.com
We have tried to run the above command for the other colleagues using the RunAs option in CMD, and it still works.
But We have the Java web application with Waffle SSO authentication, using Waffle impersonation,
We are calling the batch file which consists of steps involving SSH/SCP using windows API CreateProcessAsUser.
Java application is running as Windows Service in order to impersonate the user and create a new user in the logged-in user context.
When I logged into the Java application and tried to run a Batch script, it works fine. SSH and SCP worked perfectly!
But when the other users try to log in and execute the batch script using the createProcessAsUser function. SSH and SCP failed. Facing the below issue
Note: I have RDP access to the remote machine where the Java application runs and my user profile is loaded into the machine. I have generated SSH private/public keys and registered them in respective systems. To test the GSSAPI/Kerberos Authentication, I have removed the key pairs and renamed ~user/ssh to ~user/ssh1. Still, it works fine. Irrespective of RDP access and SSH key, Kerberos/GSSAPI works perfectly using CMD. But it fails for other users when they access it from a Java application.
sshd_config:
Any pointers or suggestions would be grateful!
Till now I was able to launch multiple EC2 Windows instance & get its parameters (password / IP) with aws-api-tool .
Now I'd like to find a way to execute the selenium grid command on all those instances. Is it possible to do this with automation?
If any one can give me a sample program for this, that would be helpful.
I am running Windows server 2008 on all those instances.
The Amazon EC2 Systems Manager Run Command can run commands on multiple Amazon EC2 instances.
It requires installation of an agent. Commands can then be run via the Management Console, AWS Command-Line Interface (CLI) or API calls.
Using ubuntu 11.10. When I run jvisualvm from the command line, the output is : "No protocol specified". Then the program exits.
Jayan is right about this looking like a DISPLAY error, which can happen when you're trying to run commands on the same machine as a different user or on a remote machine. Here's a quick way to fix it if you're not worried about security.
Type xhost + on your local machine as the main user (the user who can start programs that bring up windows, such as xterm).
If you're running a command as another user on the same machine, you'll probably be able to do it now. If not, try export DISPLAY=localhost:0.0 as that user.
If you're running a command on a remote machine, but want it to show up on your local machine, try export DISPLAY=YOUR_IP_ADDRESS:0.0 on the remote machine.
I encountered it when trying to run JVisualVM on my local machine as user mapred to analyze some Hadoop jobs. I could imagine having to log into a remote machine to do it when Hadoop is running across a cluster (instead of on my local machine in pseudodistributed mode).
(The comment about security: xhost + will allow anyone on the Internet to pop up windows on your computer if they know your IP address. The effect of xhost resets when you reboot, so it's usually not an issue on a personal computer.)
Did you try running any other application with GUI? If they too fail with similar error, it related to display setting.
One way to get this error is not having correct DISPLAY defined. (Please post the full exception. )
My main goal: Collect specific information through the linux server on a windows machine. I want this program to ask the user for information needed and the program will log into the linux server with credentials "hard-coded" in the software and obtain the appropriate specific information the user requested.
My situation: This program will be used with different OSs (Mac, Windows, Linux, etc.). I have written a Perl script that does the task I want, but to run the script, you have to be on the linux server, but I want the user to not have to log into the linux server. I do have PuTTy on my computer which is what I use to log into the linux server. I don't know if that will be useful.
My program steps:
1) Once the user opens the program, a GUI will display different elements that the user interacts with. These elements ask for information that will aid in obtaining the specific information through the linux server.
2) Connect to the linux server. This is the tricky part. If I'm coding in Java, for example, making a normal application with Swing and I'm running on a windows machine, how can I connect straight to a linux server, enter commands, and obtain output information and send it to a text file?
3) Take the information that would have been outputed to the terminal screen and send it to a text file on the linux server and/or locally.
4) Finishing touches.....(closing the terminal, telling the user success or fail, etc.).
Like I said above, I have written a Perl script that you can run and will obtain all the information and send the output to a text file and do every thing I want it to do, but I want this to be more interactive and "user-friendly" and not have to make the user log into the linux server, but simply just open a program and click a few buttons. The program will log into (This login info would be the same username and password every time) to linux server, send the required information to a text file, and do everything for them.
Thanks in advance!!
Plink program from Putty site should be able to do what you want. See http://the.earth.li/~sgtatham/putty/0.62/htmldoc/Chapter7.html#plink Problem would be with SSH fingerprint, that has to be confirmed first time from putty itself, not from plink.
i'm trying to execute a shell script from a j2ee application (made with flash builder 3, spring, apache cxf) et get the result of its execution in my flex interface.
the problem is my application is on a windows 7 station and i don't know how i can execute the script on a distant unix server & get back the result.
i know that ssh apis can help but i've no idea how to get back the result.
any help will be welcome.
thanx
If you have ssh installed on your windows machine, you should be able to execute a command like
ssh user#remote_host ipconfig
This will execute ipconfig on the remote_host as user "user". You will need to do a bit of research into ssh so that you can make it so you can log in without using a password, but google will help with that.
Alternatively you could look in to a java implementation of ssh - jssh for example, although I confess that I have no experience of using that package.
To execute program from windows to unix you really need ssh or telnet.
SSH is more secure. You can do this without running external process. Use one of available pure java SSH libraries (e.g. javassh.org).
See examples. If you use this library your task is trivial. Just call appropriate API.
About the only reasonable and reasonably secure answer I could come up with is to configure ssh on both machines.
*nix boxes usually have ssh server installed by default.
Putty terminal emulation for windows comes with neat ssh client command line utility called plink which can execute shell commands on a remote unix box in a secure manner.