0

I have a project in java, which i want to run only if the user is admin, for that I set system property to admin - -Duser=admin

I export my project to a jar and create its exe.

How can i set system property for exe file? How to verify if user is admin, easy in case of batch file but unable to do for exe file.

User admin does not mean windows admin user, i want to make certain people admin and use some specific features of my application.

Chetna rustagi
  • 463
  • 7
  • 21
  • why would you want an exe file? what do you mean by 'system property file'? – Stultuske Feb 15 '18 at 13:13
  • 2
    Possible duplicate of [Detect if Java application was run as a Windows admin](https://stackoverflow.com/questions/4350356/detect-if-java-application-was-run-as-a-windows-admin) – Andreas Hartmann Feb 15 '18 at 13:13
  • @Stultuske I have not referred system property file, I am talking about system properties in java which we can set with help of -D. I need exe for safety purpose, if I give it as jar to clients ,it can be decompiled. Not completely secure but a better way – Chetna rustagi Feb 15 '18 at 13:22
  • @chetnarustagi and you think an .exe can't be re-engineered/decompiled? the only way to make sure nobody gets to your code, is by not distributing it at all, only providing a client that calls your business logic – Stultuske Feb 15 '18 at 13:23
  • @AndreasHartmann Not for windows admin user, say i want to add another system property, making it admin is just an example – Chetna rustagi Feb 15 '18 at 13:23
  • @Stultuske yes, agree. – Chetna rustagi Feb 15 '18 at 13:26
  • 1
    You didn't mention which tool you are using to produce .exe file. Maybe the tool support page has the answer. – yegodm Feb 15 '18 at 13:27
  • @yegodm launch4j , thanks for the suggestion – Chetna rustagi Feb 15 '18 at 13:28

1 Answers1

0

While creating exe via launch4j , under JRE tab, we can define system properties in JVM Options as -Duser=admin

This will be same as defining any system property in run configurations of eclipse.

Chetna rustagi
  • 463
  • 7
  • 21