Run Powershell or Command Prompt as administrator during Visual Studio Team Services build - build

I am working on a project where we are delay signing the assemblies. I need to use the strong name tool a couple times during the build, to turn off strong name verification, and then to fully sign the assemblies before they are packaged. I attempted to use a powershell step to turn off verification, but it came back with this error:
Script:
$testprojs = gci Project.*.dll -r
$testprojs | % {
sn -Vr $_
write-output $("Turned off sn verification for " + $_.Name)
}
Error:
Failed to open registry key -- Administrator permissions are needed to use
the selected options. Use an administrator command prompt to complete these tasks.
So I created a script that would run the first one, but added the -elevated parameter. This made no difference.
I also tried using a command prompt step instead of powershell. This also returned the same error.
For /r %g in ("Project.*.dll") DO sn -Vr %g
When I tried running this same script rdp'd to the build agent machine itself, it works as intended. It's only when it runs as a step in the build does it not work.
Any ideas?

According to your description:
When I tried running this same script rdp'd to the build agent machine
itself, it works as intended.
I assume you are using your own build agent for build. Then this may caused by the build agent isn't running with an administrator account. Please update your build agent to run with administrator account and then try again.
Run the agent Run as a service
If you deployed the agent to run as a Windows service, then the agent
running status can be controlled from the Services snap-in. Run
services.msc and look for "VSO Agent ()". If you
need to change the logon account, don't do it from the services
snap-in. Instead, From an elevated Command Prompt, run:
C:\Agent\Agent\VsoAgent.exe /ChangeWindowsServiceAccount Run
interactively
Otherwise if you installed the agent to run interactively, the agent
can be started by launching Agent\VsoAgent.exe.
Refer to this link for details: Run the agent

Related

Is there any way to use runasoriginaluser in uninstallrun in inno setup?

I have written an application using docker-toolbox and inno setup script for the application installation in windows 10.
And I want to remove the docker-toolbox VM, while I uninstall my program. However, the VM cannot remove completely by following inno setup script.
[Setup]
PrivilegesRequired=none
[UninstallRun]
Filename: "{cmd}"; Parameters: "/C ""docker-machine rm -y myDocker"""
The command "docker-machine rm -y myDocker" always work whenever runs in my user cmd, but not works in inno setup uninstallrun.
And I checked and found out that docker-toolbox is based on VirtualBox. VirtualBox uses a per-user environment. Becoming root (or any other user) does not give you access or more powers to the original user's VMs. ALWAYS perform VM operations as the user that actually created the VMs. Hence, I have to run a command as a original user in uninstallrun, but I cannot find a way to do so.
Looking forward for a help and support, I have spent lots of times in this problem.
Is there any way to use runasoriginaluser in uninstallrun in inno setup?
You should not modify a specific user profile from an (un)installer that runs with Administrator privileges (installs software for all users).
See Installing application for currently logged in user from Inno Setup installer running as Administrator.
runasoriginaluser flag is not supported in UninstallRun section. Probably because it won't be of any use there anyway. What the flag does in Run section is that it executes program with privileges with which the installer was originally executed. But uninstaller (for installer elevated to Administrator privileges) is executed with Administrator privileges straight away, when executed from Control Panel/Settings app.

GCP Compute Engine WS 2012. Startup script dont run my .exe file after boot

My GCP Compute Engine instance running WS 2012 does not execute an executable command while using using a startup script.
Summary of steps followed:
I created a Compute Engine instance with WS 2012.
Set Metadata keys windows-startup-script-cmd with value = `"c:/prog/1.exe".
copied all needed files to local disk.(exact folder c:/prog/).
Shut down VM. (by GCP console).
Started instance from the GCP console.
And it seems that the command "c:/prog/1.exe" did not run
I saw "1.exe" process running in the Task Manager but it did not do anything . (It should have created a specific file to show that it ran successfully).
Please, tell me if I did something wrong, Or if I missed anything.
Thanks for your help .
The windows-startup-script-cmd is metadata key to run cmd startup scripts on Windows instances. The cmd startup scripts are those with .cmd or .bat extensions. You can run your executable files through a batch file. How? visit this answer on stackoverflow.

Visual Studio Team Services Build cannot deploy test agent

I've got a VSTS build that is trying to deploy a test agent so I can run some Selenium tests and when I get to the "Deploy TestAgent on" build step, I am getting the following error:
2017-06-22T14:29:05.6157972Z ##[warning]Task 'DownloadTestAgent' for
machine vmtest43xxx.cloudapp.net:5986's Error : System.Exception: The
process cannot access the file 'C:\TestAgent\vstf_testagent.exe'
because it is being used by another process.
Also, if setting up a local build agent is a good workaround for this, I'm all ears, but so far I have had a lot of trouble trying to set up a local test agent. This seems weird since setting up a local build agent was relatively easy up to this point. Any suggestions on how I should set up a local agent? I've been trying to follow instructions from here and here.
Thanks!
It’s easy to setup a local build agent, so try to setup a build agent:
Steps for windows:
Go to Admin page of Agent Pools (https://[account].visualstudio.com/_admin/_AgentPool)
Click Download agent button
Unzip the downloaded file
Run Command Line as Administrator
Run config.cmd
Specify collection url (https://[account].visualstudio.com), Personal Access Token etc
More information, you can refer to: Deploy an agent on Windows.
You can specify Test Agent Location (can be access from build agent machine) for Visual Studio Test Agent Deployment task to save time.

Setting up an Apache Spark Cluster on Amazon EC2 Using CMD

I am working on my graduation project and It's my first time dealing with spark and EC2
so I am following the steps in this blog
http://www.supergloo.com/fieldnotes/apache-spark-cluster-amazon-ec2-tutorial/#comment-3843
The problem is he is working on MAC and I don't know how to make these commands work on Windows (CMD).
for example this command
ec2/spark-ec2 –key-pair=courseexample –identity-file=courseexample.pem launch spark-cluster-example
Any Help ?!
try running it in the following way (from the same folder):
python -Wdefault "ec2\spark_ec2.py" –key-pair=courseexample –identity-file=courseexample.pem launch spark-cluster-example
if you don't know how to open console in windows - just press "Start->Run", type cmd and hit enter, then you would need to havigate to your Spark home folder, and execute the above command.
NOTE: I don't currently own a Windows machine, so I haven't tried this command myslef.

Jenkins can't copy files to windows remote host

I have a Jenkins server on OS X 10.7, which polls a subversion server, builds the code and packages the app. The last step that I need to complete is deploying the app on a remote host, which is a windows share. Note that my domain account has write access to the target folder and the volume is mounted. I've tried using a shell script build step:
sudo cp "path/to/app" "/Volumes/path/to/target"
However i get a "no tty" response. I was able to run this command succesfully in Terminal, but not as a build step in Jenkins.
Does this have something to do with the user being used when starting up Jenkins? As a side note, the default user.name is jenkins and my JENKINS_HOME resides in /Users/Shared/Jenkins. I would appreciate any help as to how to achieve this.
Your immediate problem seems to be that you are running Jenkins in the background and sudo wants to input a password. Run Jenkins in the foreground with $ java -jar jenkins.war.
However, this most probably won't solve your problem as you'll be asked to enter a password when the command runs - from the terminal you started Jenkins from (presumably it's not what you want). You need to find a way to copy your files without needing root permissions. In general, it it not a good idea to rely on administrative permissions in your builds (there are exceptions, but your case is not it).