cscript prnport.vbs Remote Desktop Connection Error 0x80041001 Generic failure - windows

I'm trying to run the following command on a remote server (Windows Server 2008r2) but it comes up with 0x80041001 Generic failure - I am running CMD in Admin mode and I know the script works as it will run on my local Windows 8 PC.
Any advice would be great!
cscript C:\Windows\System32\Printing_Admin_Scripts\en-US\Prnport.vbs -a -r TEST -h 10.227.190.10 -o raw -n 9100

My account was an Active Directory account. It had to be a local account to work :)

Related

Windows Server 2019 - Running GUI Application through OpenSSH protocol

I need to run remotely GUI Desktop App when connected through SSH.
Is this even achievable? When I try to run app(any GUI) it just hangs there and does nothing.
I need to explicitly make this work with SSH.
For anyone wondering how to run GUI applications using psexec, this is the solution:
psexec64 is located in C:\Windows
psexec64 -accepteula -nobanner \\SERVER.company.co -u DOMAIN\user -p password -h -i 2 C:\\Windows\notepad.exe
Note: You can run any exe on the server, as well as you can run locally,
also if you need to run it from linux here is solution:
First install winexe: https://sourceforge.net/projects/winexe/ - google for installing from cli
winexe -U DOMAIN/user%password //SERVER.company.co "psexec64 -u DOMAIN\user-p password -accepteula -nobanner -h -i 2 C:\Windows\notepad.exe"
Hopefully this will help someone

Powershell to connect to a remote linux ssh server and executing a command line

I have to connect from a Windows 10 / Windows Server 2016 machine to a Linux machine (CentOS) to execute a command to disable a server in haproxy. On a local Linux machine the command is sudo echo "disable server http/test1" | socat tcp:127.0.0.1:9191 stdio and it works. But I have to create a script / command line to let a Windows machine do the magic. I´ve tried powercat but it will not work. So I decide to use ssh client on the Windows machine. The command line is
ssh -l haproxy-user -i private.ppk 10.0.0.20 "sudo echo "disable server http/test1" | socat tcp:127.0.0.1:9191 stdio" but I didn´t get the option to enter the passphrase for my identy file. Or is there another option to execute the command line?

psshutdown fails unless run from admin cmd prompt

Ok here's an interesting problem I've run into. I'm attempting to reboot some computers remotely using psshutdown and getting access denied errors unless I run the cmd from a cmd prompt that was run as admin. I myself am an admin on my machine as well as on the remote computer so my credentials should work just fine.
Example code:
psshutdown /accepteula \\COMPUTER.DOMAIN.COM -u DOMAIN\USER -p Password -r -t 0
Example output:
Could not start PsShutdown service on COMPUTER.DOMAIN.COM:
Access is denied.
However when run from admin cmd window:
COMPUTER.DOMAIN.COM is scheduled to reboot in 00:00:00.
As kludge-y as it seems, is it possible to use psexec to run psshutdown as an elevated user?
After running around in circles with this I ended up using:
runas /netonly /user:DOMAIN\USERNAME "shutdown -m \\XXX.XXX.XXX.XXX -r -f -t 0"
Which isn't ideal but got the job done.
Ok, try this. It will open an external window where you can remotely shutdown computers on your network:
shutdown -i
You can type this straight into the CMD window without needing to create a .bat file.
Hope this helps!

PsExec hangs when executing batch file in bamboo continous integration server

I have a batch file on my bamboo server, that starts another batch file on an remote computer trough PsExec. If I double click the batch file on the bamboo sever everything is working fine, the batch file on the remote computer starts and PsExec exites with error code 0.
But if I start bamboo then PsExec hangs itself and the batch file on the remote computer don't start.
C:\PsTools>PsExec.exe \\<remote server> -u <user> -p <password> -s -i "C:\batchfile.bat"
PsExec v1.98 - Execute processes remotely
Copyright (C) 2001-2010 Mark Russinovich
Sysinternals - www.sysinternals.com
This is my output and where PsExec hangs.
I don't understand why it hangs only when bamboo starts the batch.
Hope someone can help me
[ Program output lost when passed through PsExec ]
there's a bug in psexec and it does redirects correctly when is called by everything different by cmd. You have few more options to start a process on remote machine:
1. http://feldkir.ch/xcmd.htm - it cannot be run on localhost
2. WMIC - also cannot be used on localhost , when host and and user/pass are given
2. SCHTASKS
This is an old question but maybe somebody has the same problem.
The first time you run psexec an eula dialog is shown. In order to avoid bamboo hanging with this dialog you may try the argument \accepteula. For instance:
PsExec.exe \\<remote server> -u <user> -p <password> -s -i "C:\batchfile.bat" -accepteula

How to execute a Windows command on a remote PC?

Is it possible to execute a Windows shell command on a remote PC when I know its login name and password?
Is it possible to do it using client PC's Windows shell?
If you are in a domain environment, you can also use:
winrs -r:PCNAME cmd
This will open a remote command shell.
psexec \\RemoteComputer cmd.exe
or use ssh or TeamViewer or RemoteDesktop!
This can be done by using PsExec which can be downloaded here
psexec \\computer_name -u username -p password ipconfig
If this isn't working try doing this :-
Open RegEdit on your remote server.
Navigate to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System.
Add a new DWORD value called LocalAccountTokenFilterPolicy
Set its
value to 1.
Reboot your remote server.
Try running PSExec again from
your local server.
You can use native win command:
WMIC /node:ComputerName process call create “cmd.exe /c start.exe”
The WMIC is part of wbem win folder: C:\Windows\System32\wbem

Resources