Silent initdb.exe postgresql - postgresql

I am trying to install postgresql on a server using a bat file. I am using initdb.exe with --pwfile option so that it picks up the password form a text file and continues...
for some reason, even with --pwfile option, it is still prompting me for a password.. Not sure what the problem is.. This is the script I am using:
set DBPATH = something
set DBADMIN = something
set DBDATA = something
RunAs /noprofile /user:%computername%\postgres ""%DBPATH%\initdb.exe" --locale=C --encoding=UTF-8 -U %DBADMIN% --pwfile="D:\Pass.txt" -D "%DBDATA%""
Thanks

If you want to install a software which requires for the installation administrator privileges and the current user account does not have the required privileges, it is possible to use command RunAs to run the installation executable and all processes started by this application with a different user account than the current user account which has the required privileges.
But the user has to enter nevertheless a password - the password for the other user account with the extended privileges to install applications. If it would be possible to run something requiring extended privileges for installing software without requesting entering the password by the user, every bad guy out in the world could very easily install trojaners and other malware (as it is possible on Windows 2000 / XP or since Windows Vista with user account control disabled).
There are systems to deploy and install software on all clients of a company like Group Policy or System Center Configuration Manager.

Related

PG Admin 4 (WEB) and inititail logon as user postgress without password

I have a fresh install of a database on AWS. I have installed PG Admin 4 for Web and set up for a user login. This works.
I find it is not possible to connect to the localhost database using 'postgres' as a user, without a password. This appears to be enforced by the dialog. Is there a way around this enforcement? How would a user only having web access ALTER this ROLE? I would expect this to be relaxed for the initial login.
The database is local to the webserver and the web server is remote for the user.
TL:DR This logon is not a peer logon as the postgres *nix user.
It's a gap in the install. A manual step will always be required to add a password for postgres for anyone wanting to use the interface for initial USER/ROLE creation. It would be nice to have had this opportunity in the setup script.
I suppose it is expected that most administrators would also add other users/roles at this time and these would be supplied to the users. Changes to config files would still be managed. They are not getting shell access.

Changing registry without admins rights windows 10

Changing registry without admins rights windows 10
What would be the best way add an entry XXX on windows registry with password
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\XXX
current permission for everyone are Read.
Tried this :
[HKEY_CLASSES_ROOT\*\shell\forcerunasinvoker]
#="Run as user without UAC privilege elevation"
[HKEY_CLASSES_ROOT\*\shell\forcerunasinvoker\command]
#="cmd /min /C \"set __COMPAT_LAYER=RUNASINVOKER && start \"\" \"%1\"\""
Coming up with Registry error:
Cannot import RegFix.reg: not all data was successfully written to the registry. Some keys are open by the system or other processes, or you have insufficient privileges to perform this operations.
If it cant be done any other option, using powershell, or an executable file, without revealing the password.
I would suggest looking into this link: http://woshub.com/run-program-without-admin-password-and-bypass-uac-prompt/
You can open registry even if it is admin protected with a batch file that runs registry with the RUNASINVOKER compatibility mode, also in this link is a registry file that allows you to run things as admin without UAC coming up. To change elements in the registry it requires administrator privileges since it affects the system configuration like how System32 cannot be edited without administrator permissions.
You cannot write to HKLM or HKCR without admin rights. There is no workaround
Ken white is correct under normal circumstances but if you use the registry file in the link (which you need administrators rights to import to registry) you can bypass UAC and run registry as admin allowing you to edit the registry.

Executing batch file for postgre dbinit with NSIS gives permission denied

Following my previous question I'm now trying to execute a batch file trough NSIS code in order to successfully setup the postgres installation after it is being unzipped. The batch file contains command for initializing the database but it fails because of permission restrictions. I am on a Win7 x64 PC. My user account is the administrator and I start the Setup.exe with Run as adminitrator option. This is the error I get:
C:\Program Files (x86)\Poker Assistant>cd "pgsql\bin"
C:\Program Files (x86)\Poker Assistant\pgsql\bin>initdb -U postgres -A
password
--pwfile "pwd.txt" -E utf8 -D "..\data" The files belonging to this database system will be owned by user "Mandarinite".
This user must also own the server process.
The database cluster will be initialized with locale
"Bulgarian_Bulgaria.1251". initdb: could not find suitable text search
configuration for locale "Bulgarian_ Bulgaria.1251" The default text
search configuration will be set to "simple".
Data page checksums are disabled.
creating directory ../data ... initdb: could not create directory
"../data": Permission denied
EDIT: After tinkering little more with the installer I got to the root of the problem. I cannot in any way execute the following command when the installation is in the Program Files folder:
initdb -U postgres -A password --pwfile "pwd.txt" -E utf8 -D "..\data"
I tried from .bat file. I tried from .cmd file. I tried manually from Command Prompt. I tried start as Administrator. All attempts resulted in the Permission denied error
EDIT2: I did not find any way to fix the problem so I made a workaround. Now I distribute the postgres with its data directory already initialized. Then I only need to create the service and start it.
I just realised what the issue here is.
If you run postgres as Administrator, it uses a special Windows API call to drop permissions (acquire a restricted token), so that it runs without full Administrator rights for security. See PostgreSQL utilities and restricted tokens on windows.
I suspect that what's happening here is that initdb isn't creating the target data directory and setting its permissions before doing that, so it drops permissions and then doesn't have the permissions to create the data directory.
To work around it, simply md ..\data to create the empty directory and then use icacls.exe to grant appropriate permissions before you try to initdb. Or, even better, store it in a more appropriate place like %PROGRAMDATA%\MyApp\pgdata or whatever; application data should not go in %PROGRAMFILES%.

No postgresql user created after new Windows install

I'm trying to use postgresql with Rails so I can run locally before deploying to Heroku. I installed the latest version of postgresql (9.2.4) from enterprisedb.com.
When I try to double click the database in pgAdmin III, it asks for a postgresql password. There is no Windows postgresql account in the user settings. I did notice that during my subsequent uninstallation of the application, the uninstaller referenced a service user account "NetworkService."
If I try to run the command line psql command, it asks for a password, then it complains that authentication failed for (my windows login account name). I tried entering my usual Windows account password, and that didn't work.
What's going wrong here? I've read many posts of people running into password/account issues with this database.
There is no Windows postgresql account in the user settings.
The installer for 9.2 doesn't create a postgres Windows user account. People were having too many problems with the service account password, getting confused between the service account and the postgres database account, etc. It now installs and runs as NETWORKSERVICE by default.
You will have set a PostgreSQL database password when you installed. You must log in to PostgreSQL as the postgres user with the password you gave during installation.
With the help of bma, I was able to get my Rails application running on Windows by following these steps:
Install postgresql for Windows.
Open the pgAdmin III application from the Windows Start Menu.
Click on the File menu, click Open pg_hba.conf
Browse to C:\Program Files (x86)\PostgreSQL\9.2\data\pg_hba.conf.
Double click each of the rows and change md5 to trust

Problems using RunAs in TestComplete7

I have a problem with running RunAs mode in TestComplete7.
I use:
var p = TestedApps.MyApp.RunAs("domain", "user", "password");
but without success.
I get this error:
**************************************************
Unable to run "MyApp" under the Domain\User account.
Make sure that the password and other parameters are valid and you have sufficient rights to run processes under another user account.
**************************************************
I'm running TestComplete in Administrator mode and I've done everything as explained in TestComplete Help.
Check out this TestComplete support article for troubleshooting tips. Some key points from this article:
Is the Secondary Logon service running?
Are the domain, user name and password valid and spelled correctly?
Try Windows runas command with an arbitrary application (e.g. Notepad) and exactly the same credentials and see if it works.
Is the password non-empty? (Accounts with empty passwords aren't supported for RunAs in TestComplete.)
Does this account have permissions for actually executing the application?