Team City Version 9.0 hangs when running a PSEXEC command - teamcity

I am using Team City version 9 on a Windows Server 2012 machine. I have a build step in my Team City project that uses psexec to runs a command line script on a remote computer. The remote computer is Windows Server 2008 Standard 32-bit with SP2. One line in the team city script is:
\\Aenyfs01\APPS1\Winstall75\PSTools\psexec.exe \\aewebsvctst4 \\aewebsvctst4\deployScripts\stopwebsite.cmd SCRIBE2QA1TEST -accepteula
When Team City gets to this line it starts running PSEXEC and then hangs. I found another thread that said to use the -accepteula to suppress the license screen.
This line is using psexec to run a command script from the remote machine called aewebsvctst4. I have psexec installed on that remote machine and ran psexec from the remote machine's windows explorer. I got the license screen and clicked OK.
When I run this command from the team city build server machine it works fine. But running in Team City just causes it to hang.
Here is the output from the build log in Team City:
[Step 2/3] C:\TeamCity_Working\Distribution\SCRIBE\Trunk>\\Aenyfs01\APPS1\Winstall75\PSTools\psexec.exe \\aewebsvctst4 \\aewebsvctst4\deployScripts\stopwebsite.cmd SCRIBE2QA1TEST -accepteula
[18:05:55][Step 2/3]
[18:05:55][Step 2/3] PsExec v1.98 - Execute processes remotely
[18:05:55][Step 2/3] Copyright (C) 2001-2010 Mark Russinovich
[18:05:55][Step 2/3] Sysinternals - www.sysinternals.com
[18:05:55][Step 2/3]
[18:05:55][Step 2/3]
Does anyone have any ideas?
Thanks,
Glenn

Related

.net core “dotnet build” command doesn't break Azure build pipeline (bash) on error

I have an Azure pipeline with a CentOS agent. The pipeline do not break on build fail. Here is a part form the pipeline yaml configuration:
- bash: |
dotnet --version
dotnet build $(Build.Repository.LocalPath)/ProjA -c Release -r linux-x64
dotnet build $(Build.Repository.LocalPath)/ProjB -c Release -r linux-x64
failOnStderr: true
displayName: build
env:
DOTNET_CLI_HOME: /tmp
How can I make it fail on build errors?
Build log:
##[section]Starting: build
==============================================================================
Task : Bash
Description : Run a Bash script on macOS, Linux, or Windows
Version : 3.151.2
Author : Microsoft Corporation
Help : https://learn.microsoft.com/azure/devops/pipelines/tasks/utility/bash
==============================================================================
Generating script.
========================== Starting Command Output ===========================
[command]/usr/bin/bash --noprofile --norc (path)be642b86-51b1-44c5-8727-71cc18ec0678.sh
2.2.300
Microsoft (R) Build Engine version 16.1.76+g14b0a930a7 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
Restore completed in 2.22 sec for (ProjA)
...
Build FAILED.
...
7 Warning(s)
3 Error(s)
Time Elapsed 00:00:05.73
Microsoft (R) Build Engine version 16.1.76+g14b0a930a7 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
Restore completed in 568.52 ms for (ProjB)
...
Build succeeded.
0 Warning(s)
0 Error(s)
Time Elapsed 00:00:03.17
##[section]Finishing: build
Yes, I've seen similar things happen with my builds running on Linux agents.
Windows has %ERRORLEVEL% to catch the return/exit code of the last executed command or script, upon querying which you would know whether or not to proceed with the rest of execution. Similarly, what you could try doing is get the right exit code from your executed command on the CentOS machine (echo $?) and pipe the output to stderr if something does go wrong indeed.
This would then mean that the task would fail as you have the failOnStderr arg set to true, resulting in breaking the build. There are also some task control options like continueOnError that we could utilize to define this behaviour:
Here are some interesting related reads:
catch native exception in dotnet core
https://learn.microsoft.com/en-us/azure/devops/pipelines/process/tasks?view=azure-devops&tabs=yaml#task-control-options
Hope this helps.

PsExec could not start app: The system cannot find the file specified

This question has been asked many times elsewhere.. but they are mostly about running things on a remote computer etc. Mine is much more straight forward.
I got an app (let's call it app.exe), which runs by a service. When it runs by the service, it is ran by the SYSTEM user.
However the app is acting weird, further when I run the same app by simply clicking on the .exe file, it runs it but with the logged in user account:
So I simply want to run the same app as system, that's where I found the psExec command. If I run the psExec command like so
c:\path\BOT>psExec "*** Bot.exe"
PsExec v2.2 - Execute processes remotely
Copyright (C) 2001-2016 Mark Russinovich
Sysinternals - www.sysinternals.com
it works just fine, but once i put the -s switch (ie to run as system).. it blows up:
c:\path\BOT>psExec -i -s "*** Bot.exe"
PsExec v2.2 - Execute processes remotely
Copyright (C) 2001-2016 Mark Russinovich
Sysinternals - www.sysinternals.com
PsExec could not start *** Bot.exe on SAMERDERNAI5012:
The system cannot find the file specified.
this answer states that if the cmd window is ran as non-admin, then it should work. I tried that but nothing happend.
I expect the bot.exe file is not in the list of directories in the PATH environment variable for the SYSTEM user.
To system the system version of PATH open system control panel (Windows Key+Break), go to Advanced System Settings, and then Environment Variables.

psexec fails against windows 10 remote target

Does psexec work against Windows 10 remote hosts? I'm running psexec from a Windows 7 machine. When the remote host is Windows 8.1, it works, when the remote host is Windows 10, it fails as below:
C:\Windows 7>psexec -h -u Admin -p passwordHere -n 280 \xxx.xx.xxx.xxx ipconfig
PsExec v2.11 - Execute processes remotely
Copyright (C) 2001-2014 Mark Russinovich
Sysinternals - www.sysinternals.com
Could not start PSEXESVC service on xxx.xxx.xxx.xxx:
The remote procedure call failed and did not execute.
Any clues appreciated.
Found this on a Microsoft forum, worked for me.
Open regedit from start. Go to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System
Add REG_DWORD (32 bit) LocalAccountTokenFilterPolicy and set value to 1.
You must run psexec on the remote machine and accept the end-user agreement (EUA) before running psexec remotely.
This can also be done by adding '-accepteula' switch to your command or by editing the remote machine's registry (less recommended).

Running psexec from jenkins not showing logs

I have Jenkins with 'Execute Windows Batch Command' that runs PsExec on a second computer configured with Execute Windows Batch Command
and set to cmd /c "FooPsExec.bat"
When I run the Jenkins I do not see the execution of PsExec logs and all I see is:
"c:\pstools\PsExec.exe" XXXXXXXXX
PsExec v1.98 - Execute processes remotely
Copyright (C) 2001-2010 Mark Russinovich
Sysinternals - www.sysinternals.com
And that's it, I can see that the process is running on the remote computer however I want to see the logs on Jenkins
If I open cmd on the Jenkins and run the FooPsExec.bat (not via Jenkins) it is working and logs are shown appropriately
How can I make the logs to be visiable
You can use PaExec http://www.poweradmin.com/paexec/, which is an advanced version of PsExec

How to ad hoc (not as a service) run Visual Studio 2010 Remote Debugger (msvsmon.exe) without UI (i.e. from PsExec)?

Is there a way to ad hoc (not as a service) run Visual Studio 2010 Remote Debugger (msvsmon.exe) without UI (i.e. from PsExec)?
I want to be able to run msvsmon without logging in to the server via Remote Desktop.
Also running msvsmon as a service is too risky.
msvsmon.exe can be run from the command line and setup using command line arguments. You can get a list of these using /?.
So the answer is yes. PsExec will just execute a command remotely. You would have to either install/xcopy the remote debugger to the remote machine, then use PsExec along with a suitable msvsmon.exe command line to start it.

Resources