6

I am building a swing application (a file explorer) that has to copy/move files/folders around. When I try to copy to some folders such as Program Files, it throws an exception (access denied). I can solve by running NetBeans as administrator.

Is there anyway I can give admin rights to my project only, without running the whole Virtual Machine as admin?

Charles
  • 50,943
  • 13
  • 104
  • 142
Bobi Adzi-Andov
  • 191
  • 1
  • 2
  • 8
  • read this:http://stackoverflow.com/questions/2206646/create-a-process-with-ordinary-rights-from-an-administrator-process – Dmitry Zagorulkin Jul 06 '12 at 11:21
  • I need it the other way around, i am not running the VM as admin, although i need my project to run as admin, i was thinking maybe change something in Project Properties under run...is that possible? – Bobi Adzi-Andov Jul 06 '12 at 11:25
  • 3
    Use "Run As" to start your program as an administrator. –  Jul 06 '12 at 16:15

2 Answers2

0

You could, for a really horrible non-cross-platform method, use VBScript's .ShellExecute and Runtime.exec to force a program to run as an administrator.

For brevity's sake, I have created a simple program available at https://dl.dropbox.com/u/26746878/Misc/JavaElevated.zip

It can be run with java Launcher.

From NetBeans, I'd assume you'd somehow get it to run the Launcher as the main class instead of the main Program.

RunasSudo
  • 483
  • 2
  • 4
  • 13
-2

Is there not a command line startup, I'm sure there is and that there is a guy(ette) out there who would write it out for us in about 10 hot seconds. Windows 7/64