I am logging on Windows server 2008 R2 using my windows account that is a memb开发者_运维技巧er of administrators group. I need to run a java program to modify some local files for which the administrators have "Change" right. But I keep getting FileNotFoundException due to access denied.
Then from the error message, I got know the file to be changed and made it changable to normal users and then I can run my java program 1 step further. But this is not the solution because there are a lot files to be changed.
Question: can I pass my administrator account and password to java.exe so that it can run with full privilege to access those files? Or any other solution?
java version "1.6.0_22". Java(TM) SE Runtime Environment (build 1.6.0_22-b04). Java HotSpot(TM) 64-Bit Server VM (build 17.1-b03, mixed mode).
If your account has administrative privileges, the simples solution would be to open a command prompt with "Run as ...", and choose you admin account. From there on, everything executing will have the needed rights. Make sure you execute your java.exe from that console.
You can start your program as administrator
To start a program as an administrator
1.In Windows Explorer, click the program executable file that you want to open.
2.Press SHIFT and hold, right-click the program icon, and then click Run as.
3.To log on using an Administrator account, click The following user.
4.In User name and Password, type the Administrator account name and password that you want to use.
Documentation
精彩评论