APPAP308E - Invalid process path. Full path is required - c#

I use CyberArk 12.1 to get database password by SDK. Application was written in NetCore3.1, we migrate it to NET6. Sadly CA 12.1 isn't compatible with NET6, support appears in 12.6, but my organisation at this moment doesn't plan upgrade
I try to execute PowerShell script from my application (NET6) to connect with CyberArk agent
Script returns from CA error
APPAP308E - Invalid process path. Full path is required
PowerShell
C:\Program Files (x86)\...\CLIPasswordSDK.exe GetPassword /p AppId=xxx /p Query="Safe=xxx;Folder=Root;Object=xxx" /p Reaseon="test"
I don't understand what means path in this context?
How can I resolve problem, what could be wrong in my script?

Script is executed in application by creating new process
Process.Start("script.bat"); // Error about path from CyberArk
There has to be entered absolute path
Process.Start("c:\\app\\script.bat"); // works

Related

How to set pipeline for building unity project in azure devOps

I am new in creating pipelines and I need to create one to build my unity project and C# scripts. I try this:
https://dinomite-studios.github.io/unity-azure-pipelines-tasks/hosted-agent.html (in this try I have not Unity Active License serial key and because of that I remove this task, but my second PowerShell script doesn't pass) for this I get this error:
Starting: PowerShell Script
==============================================================================
Task : PowerShell
Description : Run a PowerShell script on Linux, macOS, or Windows
Version : 2.170.1
Author : Microsoft Corporation
Help : https://learn.microsoft.com/azure/devops/pipelines/tasks/utility/powershell
==============================================================================
Generating script.
========================== Starting Command Output ===========================
"C:\windows\System32\WindowsPowerShell\v1.0\powershell.exe" -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command ". 'D:\a\_temp\2178f08e-dbac-43f8-a053-1a2420d6c47c.ps1'"
Find-UnitySetupInstaller : The term 'Find-UnitySetupInstaller' is not recognized as the name of a cmdlet, function,
script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is
correct and try again.
At D:\a\_temp\2178f08e-dbac-43f8-a053-1a2420d6c47c.ps1:3 char:41
+ ... tall-UnitySetupInstance -Installers (Find-UnitySetupInstaller -Versio ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Find-UnitySetupInstaller:String) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : CommandNotFoundException
##[error]PowerShell exited with code '1'.
Finishing: PowerShell Script
and this:
https://medium.com/medialesson/continuous-integration-for-unity-3d-projects-using-azure-pipelines-e61ddf64ad79 for this I get this error:
Starting: Unity Build Android
==============================================================================
Task : Unity Build
Description : Build a Unity project and get the exported output files.
Version : 3.1.1
Author : Dinomite Studios
Help : Builds a Unity project to supported build target platforms. [More Information](https://github.com/Dinomite-Studios/unity-azure-pipelines-tasks)
==============================================================================
Determining Unity editor version for project at D:\a\1\s\virtualterminal-realwear\VirtualTerminal
Success, Unity editor version found 2019.3.9f1, alpha=false, beta=false
Unable to locate executable file: 'C:\Program Files\Unity\Hub\Editor\2019.3.9f1\Editor\Unity.exe'. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also verify the file has a valid extension for an executable file.
##[error]Unable to locate executable file: 'C:\Program Files\Unity\Hub\Editor\2019.3.9f1\Editor\Unity.exe'. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also verify the file has a valid extension for an executable file.
Finishing: Unity Build Android
and I try with only "VisualStudioBuild" Task, but nothing doesn't work.
Can someone tell me how to do it right?
Find-UnitySetupInstaller : The term 'Find-UnitySetupInstaller' is not
recognized as the name of a cmdlet, function, script file, or operable
program.
For the first error your encountered, if you check the log of first Powershell task, you will find one warning message: WARNING: User declined to install module (UnitySetup). In another word, the module UnitySetup is not installed successfully even the task is pass with green. Our Azure devops system refuse to install this module.
That's why you encountered the cmdlet xxx is not recognized error. That's because the parent module UnitySetup has not installed successfully yet.
To resolve this issue, Need to append -Force parameter after the Install-module command in first Powershell task:
Install-Module UnitySetup -AllowPrerelease -Scope CurrentUser -Force
##[error]Unable to locate executable file: 'C:\Program Files\Unity\Hub\Editor\2019.3.9f1\Editor\Unity.exe'.
According to the second log you shared, you are using Hosted agent, right? And seems also you didn't add Unity Get Project Version task and Powershell tasks to install Unity tool into environment since you were following the pipeline definition sample of this blog.
If you review that blog carefully, you will find that the blog author has pre-installed the self agent on local machine manually before he configured the pipeline in Azure devops, along with Unity Hub installed on the agent.
In short, the Unity.exe has been exists in author's building environment, so the installing Unity steps with Powershell scripts omitted here. BUT our Hosted agent has not installed this executable file in our machine, which means you must install it by yourself when you are using Hosted agent.
Per my opinion, I strongly suggest you to follow the second blog you mentioned to configure your pipeline which can save your build execution time:
1) Install self agent first.
2) Install Unity.exe and needed unity version.
3) Configure pipeline.

using C# with PIG on HDInsight Azure

I am working with HDInsight .NET SDK to use C# sdk with pig. I am getting error when specifying the c# application path.
here's how am defining the C# app in pig script
DEFINE pigudf `PigUDF.exe` SHIP('wasb://book#storage.blob.core.windows.net/PIG/app/PigUDF.exe');
am getting error "invalid ship specification" 'wasb://bookstore#storage160203122480.blob.core.windows.net/PIG/app/PigUDF.exe' doesn't exists, however PigUDF.exe does exists at the given path.
If I run the same query from HDInsight cluster console with both pig script file and c# app stored locally on cluster, it runs successfully.. i.e the below works on hdinsight cluster console
DEFINE pigudf `PigUDF.exe` SHIP('C:/PigUDF.exe');
where pigudf.exe is locally stored on cluster.
I even tried running it through HDInsight tools for visual studio, but I get same error.
Any help here will be appreciated.
thanks,
Saleem
Try using http:// instead of wasb://. The wasb protocol is used to access Windows Azure blob storage.
DEFINE pigudf `PigUDF.exe` SHIP('http://book#storage.blob.core.windows.net/PIG/app/PigUDF.exe');
You can copy your udf to local, update its permissions, ship it, and eventually remove it
fs -copyToLocal wasb://<container>#account/udf.exe
sh cacls udf.exe /E /G <group>:F
define myUdf `udf.exe`ship('udf.exe')
-- run your computation...
sh del udf.exe

Getting permission for accessing an existing file in setup created using Inno Setup

I am a new C# programmer. I made a setup file of an application in Inno setup, but when I use this application after installation, the application crashes when it tries to access (read) an existing folder in the computer (which the user has permission to access otherwise). This folder does not contain any program file, or logs. It just contains some media files which are already in the computer.
I saw the Inno script format, but it shows only how to give permission to access program files/folders only, what about the files which are already there in the computer? Shouldn't the application should have access to files which the user (who installed it)has access to ?
To set permissions on existing files or folders, you can use the Windows cacls command in the [Run] section.
Filename: "{sys}\cacls.exe"; Parameters: """C:\My Folder\My File.ext"" /t /e /g ""Everyone"":f ""Power Users"":f ""Users"":f ""Authenticated Users"":f "; StatusMsg: "Configuring Windows settings..."; Flags: runhidden
Type cacls /? at a command prompt for all available switches and syntax.
It worked when I used
"Permissions: users-modify" in [Dirs] section.

asp.net MSDeployEnableWebConfigEncryptRule fail to encrypt web.config

I have added <MSDeployEnableWebConfigEncryptRule>true</MSDeployEnableWebConfigEncryptRule> to .pubxml file in order to encrypt web config file. However, when publishing, i got the following error. I do not know whether there is extra setting needed in the web.config file other than inserting <MSDeployEnableWebConfigEncryptRule>true</MSDeployEnableWebConfigEncryptRule> in .pubxml
Error:
Web deployment task failed.(Fail to encrypt destination web.config. Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_FAILED_TO_ENCRYPT_WEB_CONFIG.)
Note: #ERROR_FAILED_TO_ENCRYPT_WEB_CONFIG does not appears anywhere on the given link.
How could i resolve this error? (note: i do not wish to pre-encrypt the web.config file locally before publishing it)
The problem seem to be that MSDeployEnableWebConfigEncryptRule doesn't work with MVC project that have multiple web.config files. Typically MVC project has Views/Web.Config file. This seems like a bug with MSDeploy.
My Workaround is to have a post deployment powershell script to perform same command on the destination server. See http://www.iis.net/learn/publish/using-web-deploy/web-deploy-powershell-cmdlets
Powershell Script Sample:
Add-PSSnapin WDeploySnapin3.0
$cmd = '%windir%\Microsoft.NET\Framework\v4.0.30319\ASPNET_REGIIS.exe -{0} {1} "{2}"' -f 'pef', 'connectionStrings', $destinationFolder
New-WDPublishSettings -UserId $UserName -Password $Password -ComputerName $destination -AllowUntrusted -FileName server.publishsettings -AgentType MSDepSvc -Site $Website
Invoke-WDCommand -Command $cmd -DestinationPublishSettings server -Verbose
I was getting this same message too.
I looked in the Web Deployment logs in the Event Viewer > Microsoft Web Deploy. The Exception it was giving me was:
ERROR_FAILED_TO_ENCRYPT_WEB_CONFIG
Microsoft.Web.Deployment.DeploymentDetailedClientServerException: Failed to encrypt destination web.config: .... Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_FAILED_TO_ENCRYPT_WEB_CONFIG. ---> System.Security.Cryptography.CryptographicException: Object already exists.
Googling this led me to this answer from "Just TFS": Release Management Agent not connecting
Which said "The Deployer user (\) does not have access to the crypto store. On the server where the deployment agent is installed, navigate to this folder %ALLUSERSPROFILE%\Application Data\Microsoft\Crypto\RSA\MachineKeys and give read/write access to \. – Just TFS Sep 3 '14 at 12:08"
So I attempted to give my MS Deployer user account read/write to that MachineKeys folder but it denied me access to do so. I ended up adding the deployer user account as a local Administrator and that did the trick.
Was able to deploy with it encrypting the web.config file successfully to the server.

Win32_Process.Create() can launch local files but not network files

I am attempting to remotely call an executable on a target machine, with the executable located on a UNC network path. I am using the Win32_Process.Create method to do this. I am able to use this method to launch files that are stored locally on the C: drive, but I get Return Value 2, Access Denied, when I try to launch the file from a UNC path. I am confident the path is correct, because if I alter it to a bogus path, I get Return Value 9, Path Not Found.
In Powershell I am using invoke-wmimethod to call the Create method of Win32_Process and passing a credential object that has administrative rights on the target system and read rights on the UNC path. In C# I am impersonating using ConnectionOptions with the same credentials. The results are the same in both cases.
I have also tried using various methods (CIM_DataFile, remotely invoking XCopy) to copy the EXE file locally first. None of these methods have worked. I want to copy directly from a file server, to a target system, without pulling the file to the application server first, because the application server is not in the same datacenter as most target systems and as such would be pulling a large file down over the WAN twice, which is slow and less reliable. One option I have found is to use FTP, but I consider that a last resort.
I can also remotely invoke the EXE from the UNC path using PSExec and the same credentials, but I want to avoid shelling out from my web application to call PSExec. I know it will work if that's what I have to do, and I have used PSExec many times to solve problems like this, but I really want to do this all within the application and not hacking around it using an external program.
Is there any way I can use Win32_Process to launch an EXE on a remote machine, when that EXE is located on a UNC path? Could this be a Group Policy issue wherein the process launched by WMI does not have permission to invoke an EXE from a network location? I am out of ideas and out of search terms.
Powershell code examples. This works:
$launchproc = Invoke-WmiMethod -ComputerName $compName -Class Win32_process -Name Create -ArgumentList "c:\temp\installer.exe /s /f1c:\temp\installer.iss" #-Credential $adminCreds
This does not:
$launchproc = Invoke-WmiMethod -ComputerName $compName -Class Win32_process -Name Create -ArgumentList "\\fileserver\share\installer.exe /s /f1\\fileserver\share\installer.iss" -Credential $adminCreds
Note that if I issue the command locally from a command window, interactively, the UNC based command DOES work just fine. The funny syntax is an artifact of InstallShield's silent install switches. Also note that if I double-backslash or backtick escape the backslashes, I get Path Not Found, so I don't think it's an escaping issue.
Edit: while not exactly the same problem, I did check the GP rights described here: WMI Win32_Process.Create fails with Insufficient Privs and I do have those rights set correctly.
Edit #2: I found someone else having a similar problem:
Win32_Process Create method. Trying to copy a file from a remote machine to a remote machine Again it's a batch file-ish hack launching Net Use on the remote system. Is this my only real option?
In the end, I just called PsExec using System.Diagnostics.Process() in C#. It's not the solution I wanted, but I wasn't able to make anything else work, and while I don't like shelling out to an external EXE, it does end up being relatively straightforward.
I asked some of the PowerShell MVPs who are more knowledgeable in WMI and got the response that unless the remote machine was the domain controller you won't be able to do it. However, if you could use PowerShell remoting to remote to the computer with -Authentication CredSSP, then you could use Invoke-WmiMethod with the network path. Richard Siddaway did a write up on this that might be useful to peruse.

Categories

Resources