How to execute Powerpoint on a remote computer using psexec - psexec

I have a remote computer I'd like to launch a powerpoint presentation remotely using psexec. I would like the powerpoint presentation to launch on the REMOTE computer.
I'm trying to execute the following command and it says "invalid file name" I have verified the file exists
psexec -u domain\user -p password \remotepc -h C:\Test\Test.pptx

Try:
psexec \\remotepc -u domain\user -p password -h -i C:\Test\Test.pptx
Notice you have 2! slashes before the remotepc name.
And I added the -i option.

Related

What is meaning of 1/0 in PSExec command?

I am using PSTools to remotely running the application in Windows machine using the command
PsExec.exe \Machine-i 1 -u Username -p Password -d /accepteula
C:\Test\PsexecConsole.exe
My question is what is the 1 means in the command?
As stated in the documentation of the PsExec.exe application the -i switch is used to identify the session on the remote system:
-i Run the program so that it interacts with the desktop of the specified session on the remote system. If no session is specified the process runs in the console session.

What does psexec -s do?

I want to run some commands on the remote machine. I am using psexec.exe in my application, when I try to run some command using -h and -s arguments as mentioned in the below command.
C:\psexec.exe -accepteula \\IPAddress -h -u "Username" -p pwd -s netstat -bno
When we provide a valid username and password it works with provided credentials, but when we provide username and password which is not valid it picks up -s and works I have done some research on -s it says -s = Run the remote process in the System account.
What exactly -s command do, when running above mentioned command on a particular remote machine with the arguments like -h and -s together is user passed Username and Password will be preferred over -s?
With -s your command is executed with the System account. The System account is a special Windows account used to run core Windows services (more info here and here); this account also has special privileges, for example access to registry keys that is denied to all other accounts.
As you can read in the linked docs:
This account does not have a password
so you don't have to specify a password when using the System account.
This is how PsExec works:
When you add the -s parameter the command is executed with the System account, so -u and -p parameters are ignored.
If you specify -h (but not -s), then account and password (-u and -p) are used to connect and execute the process with the account's elevated token (if available), so they must be correct.
If you specify -h together with -s then account and password (-u and -p) will NOT be used to connect, since the command will be executed with the System account anyway.
You can double check this behavior launching a program on a remote server and looking at the task manager of the remote machine: you will see that, using -s, the program will run under the System account, otherwise it will run under the user specified with -u.
For example if you run notepad with this command:
psexec \\remote_server -u domain\user -p correct_password -d -i -s cmd /c notepad.exe
or with this command:
psexec \\remote_server -u domain\user -p correct_password -d -i -s -h cmd /c notepad.exe
or with this command:
psexec \\remote_server -u domain\user -p wrong_password -d -i -s -h cmd /c notepad.exe
in all these three cases notepad is executed under the System account:

pg_dump windows command prompt invalid command

trying to using pg_dump to backup a postgres db
i connected through the command prompt and here is my command following this tutorial http://www.postgresqltutorial.com/postgresql-backup-database/
pg_dump -U postgres -W -F t lucz_2017 > X:\postgres_backup\lucz_backup.tar
it gives me an error
Invalid command \postgres_backup. Try \? for help.
what am I doing wrong?
the db name and paths are correct
windows 7 running this from the CMD
You are running pg_dump from psql. Get out of psql and run pg_dump command from Windows Command prompt. pg_dump is its own executable, different from psql.
This works for me in Windows PowerShell in Windows 10:
.\pg_dump.exe --username "yourUserName" --no-owner "yourDatabasName" >./filename.sql
To backup my "DVD_RENTAL_DB" database to a local folder on my computer I had to use the below in the Windows command prompt while running it as an administrator:
Don't use shell redirection (>) on Windows with pg_dump. The shell will helpfully "correct" encoding issues and corrupt your dump.
Instead, specify the output filename with the -f option:
"C:\Program Files\PostgreSQL\14\bin\pg_dump" -U postgres -p 5432 -W -F p -h localhost -f C:\Postgres_DB_Backups\DVD_RENTAL_DB.sql DVD_RENTAL_DB
This worked for me ONLY after I put double quotes around the pg_dump executable file path, before when I was adding the file path without double quotes the back up was not working; probably due to spaces in my file path. The PostgreSQL documentation didn't mention anything about double quotes around the pg_dump executable file path.
To Restore my Database I used the following in the Windows command prompt while running it as an administrator:
1. Open the Windows Command Prompt as an Administrator and you will be in this directory:
C:\Windows\System32>
2. Then type the following:
cd C:\Program Files\PostgreSQL\14\bin\
3. Then you'll be here in this directory:
C:\Program Files\PostgreSQL\14\bin>
4. Type the following:
psql -U postgres -d DVD_RENTAL_DB -f C:\Postgres_DB_Backups\DVD_RENTAL_DB.sql
5. You'll be prompted for your password, then your database will be restored.
Steps to using pg_dump on windows
Access cmd as Admin and type
cd path_to_pg_dump PRESS ENTER
pg_dump --username your_user_name
--table=table_name --data-only --column-inserts your_database > my_table_data.sql
PRESS ENTER

postgres, psql and a bat file

I'm going around in circles and so need some help.
I want to be able to run an .sql against a database which is a scheduled task via a bat file. However when i run the bat file manually I get prompted for a password. I enter the password and then get told that....
"psql: FATAL: password authentication failed for user "(my windows login)"
'-h' is not recognised as an internal or external command,
operable program or batch file.
At the moment my bat reads...
#echo off
"D:\Program Files (x86)\PostgreSQL\9.1\bin\psql.exe"
-h localhost -U postgres -d database_name -f D:/scripts/SQL/test.sql
pause
First thing, what cmd do i need to add to populate the password request
What am I doing wrong with the rest of the statement to get it to load the .sql
Thanks
by adding this line to your config file (pg_hba.conf), you can tell postgres to allow local connections without authentication
local <database> <user> trust
http://www.postgresql.org/docs/9.1/static/auth-pg-hba-conf.html
All that needs to go into a single line in your batch file (it seems you have two lines):
#echo off
"D:\Program Files (x86)\PostgreSQL\9.1\bin\psql.exe" -h localhost -U postgres -d database_name -f D:/scripts/SQL/test.sql
pause
To avoid the password prompt, set the environment variable PGPASSWORD before calling psql:
#echo off
setlocal
set PGPASSWORD=my_very_secret_password
"D:\Program Files (x86)\PostgreSQL\9.1\bin\psql.exe" -h localhost -U postgres -d database_name -f D:/scripts/SQL/test.sql
pause
endlocal
The setlocal/endlocal commands are there to make sure the variable is cleared after the batch file was executed.
To avoid having the password in plain text in the batch file you can create a pgpass.conf file that contains the password. For details please see the manual: http://www.postgresql.org/docs/current/static/libpq-pgpass.html

PsExec run remote batch file in visible mode

I am trying to execute following command
psexec \\x.x.x.x -d -c -f cmd.exe /c d:\test\hello.bat
It runs fine and gives output
cmd.exe started on x.x.x.x with process ID 106084.
But when I login on x.x.x.x I can find the process ID but no visible batch file is launched. It runs in background.
Batch file
echo "Hello"
pause
Please tell me how to see the command window launched on x.x.x.x
Thanks in advance
I think you can look at the Session Id for your current user and pass it as parameter with -i For example:
PsExec.exe -s -d -i 2 c:\temp\MyServer MyConsoleApp.exe
To look at the current Session Id you can run query session
Sometimes the Session Id is 2 for the active user you want to start process for, so try looking for your correct Session Id and use it with -i parameter.
Try one of those:
psexec \\server -u xxx-p xxxx /accepteula -i 1 -d cmd.exe /K "cd d:\test && call hello.bat"
psexec \\server -u xxx -p xxxx /accepteula -i 1 -d d:\test\hello.bat
Alex K. is correct. Specifically, remove the "-d", which tells PsExec "Don't wait for process to terminate (non-interactive)". In fact, if you run the sample batch file above, which includes "pause", the cmd process will continue to run on the remote host (invisible to the remote host's GUI, since it's done via PSExec) until you kill that process.
PsExec.exe -s -i 2 C:\path_to_exe.exe
This need to check with the session ID variable (-s & -i)