Cannot install into c:\Program files on Windows 7 - windows-7

I have an installer written in Java using Izpack. It works OK on Windows XP, however on Windows 7 it cannot write to c:\Program Files. Strangely enough, as a user running this installer I can create folders under c:\program files, but not from the installer itself.
What am I missing ?

in order to write to this path, the installer would need to ask for and been granted run as adminsitrator privledges.
For Java:
Run the CMD prompt as admin or powershell as admin and navigate to JAVA's Bin dir....and run java.exe -jar #Full path of your jar file# that will get it the privledges

Add
<run-privileged/>
to the info part of your installer.xml.
For example::
<info>
<appname>IzPack</appname>
<appversion>4.2.0</appversion>
<authors>
<author email="" name="Julien Ponge (project founder)"/>
<author email="" name="The fantastic IzPack developers and contributors"/>
</authors>
<url>http://izpack.org/</url>
<javaversion>1.5</javaversion>
<requiresjdk>no</requiresjdk>
<run-privileged condition="izpack.windowsinstall.vista|izpack.macinstall"/>
<summarylogfilepath>$INSTALL_PATH/installinfo/Summary.htm</summarylogfilepath>
</info>

You need to run the installer as admin. Only admin can write to the Program Files directory. Usually when a user tries to make changes, the UAC asks if you're sure. This isn't necessarily true for a program.

Have you tried with Run As... Administrator option ?

Run cmd with administrative privileges
java -jar ***.jar

Related

Is there a method of running an application as a standard user?

I am currently testing permissions as an administrator and need to test something as a standard user. There are ways to make standard users run as administrator, but I can't think of a way to run as a standard user as an administrator. If I were to remove my administrator rights, it would take awhile for IT to give me my admin rights back. Is there a better option that doesn't include setting up my dev environment as another user? I'm trying to run Visual Studio as a standard user, if that helps.
Thanks in advance
Create a file with the contents "filename.reg":
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT*\shell\forcerunasinvoker]
#="Run without privilege elevation"
[HKEY_CLASSES_ROOT*\shell\forcerunasinvoker\command]
#="cmd /min /C \"set __COMPAT_LAYER=RUNASINVOKER && start \"\" \"%1\"\""
Run the file and apply registry changes, and then right click "Run without privilege elevation" on the file that needs to be tested. Found this solution from another thread! Thanks!

Run jar file without admin rights

I have a runnable jar file, that I start with
java -jar myFile.jar
on Windows. A customer stated that he had problems starting the application (which is this jar file wrapped into an executable). I have the suspicion that it has something to do with admin rights. So I'd like to run my jar file without admin rights for testing purposes (because this way I get the System.out/err which helps greatly for debugging).
I realize that I can just create a non-admin account and start the application there, but I'd like to know if there is a way to specifically start a jar from an admin account so that it doesn't have admin rights in the console. Or alternatively: Is there a way to open up a console that has no admin rights from an admin account?
The customer uses Windows XP, so this is the operating system that I can use. (Although if you know something in a newer Windows like Win7, I appreciate it if you would tell me too).
EDIT: To clarify: I am looking for something like this
java -jar -runWithoutAdminRights myFile.jar
or
start /runWithoutAdminRights java -jar myFile.jar
or a way to open up a non-admin console from an admin account.
The Runas command definitely looks like the way to go.
I believe the way to go about this would be to first check the trust level options available to you:
runas /showtrustlevels
You should get something like the following:
C:\Windows\system32>runas /showtrustlevels
The following trust levels are available on your system:
0x20000 (Basic User)
You would then take the value for "Basic User" and run something like the following to start java:
runas /trustlevel:0x20000 "java -jar myFile.jar"
You can follow the below steps:
Log in as the Administrator
Open the command line
Go to System32 folder (cd C:/Windows/System32)
execute: runas /user:computer_domain_name\user1 cmd
You will be asked to provide the user1's password. Afterwards a new command line opens with the user1's rights.
I have tried it and it worked.
In conclusion you can write a very simple batch which performs the steps 2,3,4 automatically so that when you click it, a command line will open with the rights of another user.
I hope this helps.
edit registry is best way to run jar file with administrator automatically.
is easy if you have setup for java application.
go to following path in registry:
HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers
create a key(String Value) with following specification:
ValueName: java path+javaw.exe(example c:\program files\java\jre7\bin\javaw.exe)
ValueData: "WINXPSP3 RUNASADMIN"
Now All Jar Files Runs to Administartor

Permissions Elevation for Windows 7?

Ive got a java app which needs to execute a driver installer exe file. On Linux we type "gksudo myCommand". Is there a way to elevate permissions from Windows command line?
You may run every application in windows with a different user e.g. Administrator. But the user who executes this command needs to have the credentials to do so.
Edit.:
In advance you can lookup the User Account Control (UAC) which is available in Windows 7 and Vista if it is possibly an alternative for you.
I decided to deploy an executable binary onto the system which calls the jar. This way the user can right click and run as administrator... That didn't work... SO I kept looking... Check this out..
Elevate.exe.. It's basically like Windows GKSudo!!!!
http://www.robotronic.de/elevate.html
So... I packaged the 32bit exe into my program and deploy it, then run it as necessary.
You can use runas command like runas /user:Administrator myCommand (it requires the users to type password).
You can also use Start-Process cmdlet like Start-Process -Verb runas myCommand in PowerShell (it requires the users to click the UAC dialog).
see: http://satob.hatenablog.com/entry/2017/06/17/013217

Windows UAC do not popup (Access Denied)

I have made an installer using izpack which is packaged as an executable jar file.
Normally when I double click the jar/installer file the windows 7 UAC box pops up and I grant temporary administrator rights when installing the application (my UAC level is second lowest).
But for some reason this box no longer pops up when I double click the jar file. As a consequence I get an error "Access Denied" when the installer tries to install a windows service (during this process some keys are set in the registration database).
Any ideas on how I get windows to recognize the jar file as an installer and pop up the UAC box as previously?
It works fine if I open cmd in administrator mode and cd to the jar file and run it from there. But it could be nice to make it work the other way (correct way).
Izpack/izpack2exe will prompt for UAC privilege elevation if you add the element <run-privileged/> to the <info> section of the config file.
Or, if you name the installation executable to include "setup.exe" or "install.exe", Vista and Win7 should automagically prompt for UAC privs. (But this isn't foolproof, as an end-user may download your app and change the name, or if you use a JAR distribution...)

Why can't Perl launch telnet under Windows?

I had enabled telnet client feature on Windows 2008, and tried to launch it from a Perl script:
perl -e "system('c:\windows\system32\telnet localhost')"
Then I got an error like this:
'c:\windows\system32\telnet' is not recognized as an internal or external command,
operable program or batch file.
I could run it from 'cmd' terminal, or, if I copy the telnet.exe to local dir, it could be launched. I examined the permissions of telnet.exe under c:\windows\system32, no special finding.
Could anybody help me on this case? Thanks a lot!
I ran into the exact same problem recently, trying to launch telnet and the rdp client programmatically. The problem is related to an aspect of windows "design" called file system redirection:
"Windows on Windows 64-bit (WOW64) provides file system redirection. In a 64-bit version of Windows Server 2003 or of Windows XP, the %WinDir%\System32 folder is reserved for 64-bit applications. When a 32-bit application tries to access the System32 folder, access is redirected to the following folder: %WinDir%\SysWOW64. By default, file system redirection is enabled."
http://www.codeproject.com/tips/55290/Disabling-Windows-file-system-redirection-on-a-CFi.aspx
I think you have to specify the full name of the program, that is telnet.exe. But you'd be better off using Net::Telnet module or something like Expect.pm that handles interactive sessions programmatically.
hi you are using Perl, so i was wondering why you don't use Net::Telnet, instead of the telnet.exe of windows, which AFAIK is not friendly for programming.
On my computer following code works (Windows 7):
$telnet = $ENV{'WINDIR'} . '\system32\telnet.exe';
system("$telnet 192.168.1.1");
It must be either a) permissions b) incorrect path, c) you need .exe at the end or d) you need to capitalise the "c:"
You might want to verify under what account Perl execute and check if that account has permissions to run executables like telnet.
Just to verify the theory, I'd run Perl under a high privileged account (like admin) to check if it runs telnet and then tweak the account it is running under.
Hope this helps!
Read about console host.
ConHost represents a permanent change in the way that console application I/O is handled.
See also a related post on SysInternals forums.
I do not have access to any Windows Server 2008 machines right now, so I cannot test this, but can you check what happens when you run wperl -e "system('c:\windows\system32\telnet localhost')" from the equivalent of Start -> Run on that OS.
The answer is: using sysnative instead of system32, because the 32-bits application is not allowed to have access to the system32 directory (64-bit application). By using this alias sysnative it wil work.

Resources