Copying file into system32 of windows 7 using java - java

i am trying to copy files which are in jar file to the system32 folder of my machine using the following code
Runtime r=Runtime.getRuntime();
Process p=r.exec("cmd /c copy hello.dll c:\\windows\\system32\\");
But here the file is not copied???!!!!
but when iam giving
Runtime r=Runtime.getRuntime();
Process p=r.exec("cmd /c copy hello.dll c:\\windows\\");
the file is copied to the windows folder......
can any one help me..........
iam using a windows 7 machine

The app needs to be run as Administrator or you must prompt the user to raise their permissions to Administrator. In Windows 7, it is insufficient for the user to have Administrative privileges--as they could in xp. They must explicitly give the application permission to perform such a copy.

Make sure your command prompt(or IDE) is running in an Administrator mode, if your are running your program via command prompt.

Related

Why opening a jar file thru ssh on a windows vm opens the browser incognito?

If I open manually (java -jar name.jar)it works. When I try to open it with ssh command it opens the browser incognito.
I have a windows vm with windows server. JDK is installed.
I can imagine you have proper installation (your question details was little bit ambiguous) but in any case it could be the java command is not on the command search path for your user account and take this steps to make sure about installation
verify that Java is installed java -version
Confirm the PATH variable includes Java’s \bin directory in your remote machine
After verification create shell file and execute shell as ssh user#host "sh ~/app-runner.sh", you may also see here to how create shell for executing jar file(s).

how to automatically install Visual C++ Redistributable for Visual Studio 2015 used in a java code

For running a java code (that includes a JXInput code for a Joystick use), I only run this .bat:
jre1.8.0_66\bin\java.exe -Djava.library.path=d:\HG -jar HG11.9.jar
But, that works if I has PREVIOUSLY installed the VC redistributable.
As some people are not software specialists, they don't know how to install this vc_redist_.exe from https://www.microsoft.com/en-US/download/details.aspx?id=48145. I mention "" because it depends on the system they have (vc_redist.x64.exe or vc_redist.x86.exe).
I am sure that this problematics consisting in facilitating procedure of installation of a game and, more generally, a product has been already solved. So, what is the good practice to manually avoid to install the vc_redist?
In other words, is it possible to include this vc_redist in the .jar? Then, only running a .bat (like above) allowing to run the game.
If not, is it possible to run a single .bat or something else that:
- unzip the .zip file of my game (this file includes the game and the vc_redist)
- then automatically install the vc_redist, depending on the system (32 or 64 bits) - by what means?
Thanks a lot for your response
If you already have bat file for install best way to do this will be to include install of vc_redist in this *.bat before install. From what I know it is not posiible to include this in the *.jar. Better will be to pack all files into zip (together with this *.bat script).
To install vcredist in bat silently you will have to add these commands:
#echo OFF
reg Query "HKLM\Hardware\Description\System\CentralProcessor\0" | find /i "x86" > NUL && set OS=32BIT || set OS=64BIT
if %OS%==32BIT runas /user:Administrator %~dp0\vcredist_x86.exe /q /norestart
if %OS%==64BIT runas /user:Administrator %~dp0\vcredist_x64.exe /q /norestart
#rest of your script
Checking if system is 32bit of 64bit is taken from here (batch file to check 64bit or 32bit OS)
%~dp0 resolves to the full path of the folder in which the batch script resides.
Edit:
As the runas might not be the best solution to problem of running this as administrator I will direct you to these posts to read about running with administrator privilages in bat
How to code a BAT file to always run as admin mode?
How can I auto-elevate my batch file, so that it requests from UAC administrator rights if required?

run a jarfile in a different machine from an sqlserver/issue a terminal command from an sqlserver to another windows machine

I have a series of stored procedures(say, SP1, SP2, SP3) consecutively running on an sqlserver(say, serverA).
After SP3 finishes execution, I want to run a jar file in some machine (say, computerA). Is there a way for me to trigger the run of my jar file in computerA after SP3 finishes executing in serverA?
Note: I can only run my jar file in computerA because my jar file actually retrieves data from Bloomberg API. So, this jar file needs to run in a machine that has Bloomberg terminal on it. Only computerA has a Bloomberg terminal.
I think another way of saying this is how to issue a terminal command from an sqlserver to another windows machine. Because I can just issue the following command to computerA but I really don't know how to make that possible.
java -jar D:\Runnables\myJavaApp.jar

how to run executable jar file on one machine from other machine

I have a executable .jar file in a remote machine in windows environment. Now I want to execute this .jar file from other machine (windows environment) and need to open the console.
So far, I have shared the specific .jar file to everyone and created a .bat file in local machine with the below content.
#ECHO OFF
java -Xms512m -Xmx768m -XX:CompileThreshold=8000 -XX:PermSize=256m -XX:MaxPermSize=512m -Dvendor=shell -DvendorFile="\\<REMOTE MACHINE'S IP>\WorkJars\servers_prod_remote.properties" -Dfile.encoding=UTF-8 -Dyfs.logall=N -jar "\\<REMOTE MACHINE'S IP>\Users\tcs\Desktop\Status Compare\statuscompare4.jar"
It works fine for some machine, but for other machine, it fails and it prompts for the username and password of the remote machine.
Even if I try accessing the remote path from local using run command \\<REMOTE MACHINE'S IP>\, for some machine, it prompts for the username and passoword for security.
Security Prompts
So whenever, I use .bat file from those local machine, it says "Access Denied".
Could anyone help me with this issue, as I don't want the username and password to be prompted and I just want to execute the .jar file without any issues.
If the jar file is excute on your machine, then the file is ok no issue with file.
Now your problem is it is not executing on some of the other machine not all. Its simple java need JRE to run or JDK for development.
Downlaod JRE java runtime enviroment from Oracle on the machine on which the file is not running and test it.
hope your problem is solve.
Another way is to quicky test if JRE is installed on the machine.
Open comand promte by clicking on start and type cmd. then type java - version
if it display some verison of java or something that means JRE is installed otherwise some other issue.

java virtual machine launcher error: unable to access jarfile

I have downloaded a program to run on windows XP.
According to the instructions, opening the .bat file that includes the command that calls the .jar file would be enough.
Yet the program does not open.
In a friend's computer the program does open.
I have set correctly the java-related environment variables. Java works fine. I have associated .jar files with java sdk.
When calling the command
javaw -Xms128M -Xmx512M -jar filename.jar from cmd
I get a java virtual machine launcher
error: unable to access jarfile
Then I called the same command while being on the folder where the jar is, I have no error, but still the gui of the program does not open.
Any ideas?
On windows support the suggest unistalling and manually re-installing java, but java works fine in any other app.
Try some of the following:
Run directly from the .exe, so "C:...\jre\javaw.exe" -jar
Try java -jar instead of javaw -jar.
Try moving the file. It could be in a permissions sensitive directory.
Also, if the program was compiled using a 64-bit JDK, it might require a 64-bit JRE to run. In that case, you'd need to have a 64-bit OS/JRE to run it.

Categories

Resources