Executing batch script from ansible control host does not work properly - batch-file

I have following very simple batch script to install Visual Basic 2017 Build Tools.
C:\packages\visualstudio2017buildtools\vs_buildtools.exe --add Microsoft.VisualStudio.Workload.DataScience --add Microsoft.VisualStudio.Workload.ManagedDesktop --add Microsoft.VisualStudio.Workload.NativeDesktop --add Microsoft.VisualStudio.Workload.NetCoreTools --add Microsoft.VisualStudio.Workload.Universal --includeOptional --includeRecommended --noweb --quiet
When I execute this script locally on the server, everything works as expected while executing it from ansible control host does not install the software. Tried many things e.g. invoke script from ansible control host and also tried to execute it locally after copying it to the remote server. It looks like the script is executing and copies few dlls from the installer but never installs the actual software/components.
Any idea what I maybe missing?
Example ansible task:
- name: Invoke batch script to install Build Tools
win_command: install.bat
args:
executable: cmd
chdir: '{{ buildtools_dst_dir }}\visualstudio2017buildtools\'
creates: '{{ buildtools_dst_dir }}\do_not_run_buildtools\'

Update:
It looks like I was missing --wait parameter in batch script when running from ansible. Adding that solved the issue.

Related

Azure Devops PowerShell Script Not Writing DACPAC Output

I'm attempting to execute a PowerShell script in Azure DevOps that creates a DACPAC file. The script completes successfully but no file shows up where it's supposed to show up. The script works properly when I run it via the PowerShell client.
The script is run inline. Here's the script:
& $(SqlPackagePath) /TargetFile:$(TargetDacPacFile1) /Action:Extract /SourceServerName:$(SqlServerName1) /SourceDatabaseName:$(DbName1) /SourceUser:$(SourceUser) /SourcePassword:$(SourcePassword)
note: not an answer
If anyone knows how one can view the $(agent.releaseDirectory) directory, I'd appreciate a tip
A lot of effort in Azure DevOps is running commands like this to work out where the hell your file is:
- task: CmdLine#2
displayName: Check Build.SourcesDirectory Path
inputs:
script: DIR $(Build.SourcesDirectory) /B /S
I resolved the issue. Apparently, Azure Pipelines doesn't have access to the file system AFAIK. I changed the target path from the local file system to $(agent.releaseDirectory)/$(TargetDacPacFile1). I was then able to pick up the DACPAC file in the next activity to deploy it.
If anyone knows how one can view the $(agent.releaseDirectory) directory, I'd appreciate a tip. Thx.

Why doesn't Inno Setup uninstall my SQL Server 2017 named instance?

I have an Inno Setup v5.5.9 file shown below;
[Languages]
Name: english; MessagesFile: compiler:Default.isl
[Files]
Source: "Setups\SQLEXPR_x64_ENU.exe"; DestDir: {tmp}\Setups; Flags: nocompression;
[UninstallRun]
Filename: {tmp}\Setups\SQLEXPR_x64_ENU.exe; Parameters: "/QS /ACTION=unInstall /FEATURES=SQLENGINE /INSTANCENAME=CASSQL";
[Run]
Filename: {tmp}\Setups\SQLEXPR_x64_ENU.exe; Parameters: "/QS /ACTION=Install /FEATURES=SQLENGINE /INSTANCENAME=CASSQL /INSTANCEDIR=""{pf}\Microsoft SQL Server\MSSQL14.CASSQL"" /SQLSVCACCOUNT=""NT Authority\Network Service"" /TCPENABLED=1 /SECURITYMODE=SQL /ADDCURRENTUSERASSQLADMIN /SAPWD=sapassword /IACCEPTSQLSERVERLICENSETERMS";
The install works just fine, but once installed, if I go to Control Panel and right-click on the installer and select Uninstall, the uninstall will remove the installer from control panel but it doesn't actually run the SQLEXPR_x64_ENU.exe or uninstall the SQL Server Express named instance.
I read that Inno Setup would automatically handle uninstall, so I removed the [UninstallRun] section, but had the same result.
I can run the following :
SQLEXPR_x64_ENU.exe /QS /ACTION=unInstall /FEATURES=SQLENGINE
/INSTANCENAME=CASSQL
From the command line and it works as expected.
[UPDATE #1 7/23/19]
I added SetupLogging=yes to the [Setup] section, hoping to see something useful in a log file. Inno Setup created the log file when I ran the install, but did not create any log file when I ran the Uninstall by right-clicking on the Inno Setup generated installer in Control Panel.
What am I missing here?
The files installed to {tmp} exist only for a duration of the installation:
Temporary directory used by Setup or Uninstall. This is not the value of the user's TEMP environment variable. It is a subdirectory of the user's temporary directory which is created by Setup or Uninstall at startup (with a name like "C:\WINDOWS\TEMP\IS-xxxxx.tmp"). All files and subdirectories in this directory are deleted when Setup or Uninstall exits. During Setup, this is primarily useful for extracting files that are to be executed in the [Run] section but aren't needed after the installation.
So at the time you run the uninstaller, the {tmp}\Setups\SQLEXPR_x64_ENU.exe does not exist anymore.
If you run the uninstaller manually from command-line and add /log=C:\some\path\uninstall.log switch, you wil find something like this in the log:
2019-07-24 08:46:04.614 Running Exec filename: C:\Users\marti\AppData\Local\Temp\is-K316U.tmp\Setups\SQLEXPR_x64_ENU.exe
2019-07-24 08:46:04.614 Running Exec parameters: /QS /ACTION=unInstall /FEATURES=SQLENGINE /INSTANCENAME=CASSQL
2019-07-24 08:46:04.615 CreateProcess failed (2).
If you want to be able to run SQLEXPR_x64_ENU.exe during uninstallation, you have to deploy it to a different folder, like to {app}.
You can can also embed the file into the uninstaller itself, if it is not too large (what it possibly is):
How keep uninstall files inside uninstaller?

How to get vscode-remote-ssh extension connects via git bash in windows?

I have vs code configured to use the git bash as a terminal in windows 7.
"terminal.integrated.shell.windows": "C:\Program Files\Git\bin\bash.exe"
I have enabled SSH key based authentication to remotely access a host. All this works fine from within the terminal in VS Code.
However, when using the vscode-remote SSH extension to connect to host I get an error because it tries to connect using "The terminal process command 'cmd.exe'" instead of git bash.
I've checked my terminal settings configuration in vs code and it points to git bash.exe
I've used the terminal extension in vs code and it opens a git bash and successfully connects to the host
Is there a setting that I'm missing to force Remote-SSH to use the git bash for the connection?
JerryL's answer lead me to realize, that I can simply set GIT's ssh path c:\Program Files\Git\usr\bin\ssh.exe in the remote.SSH.path setting of VS Code Preferences:
Then it just worked like a charm.
Just for clarity my VS Code version is: 1.40.0-insider (system setup)
I ran into a similar issue trying to get MS VS Code Studio Remote-SSH working with Putty's Pageant. I had Git for Windows installed and in a Git Bash shell, I could ssh and pick up the Pageant keys and no password was needed.
But VS Code Remote-SSH, while using the Git ssh in C:\Program Files\Git\usr\bin\ssh.exe was using Windows 7 cmd.exe shell which didn't talk to Pageant.
What worked for me on Windows 7, VS Code 1.36.1 with (Remote Development 0.15.0, Remote-SSH 0.44.0) and Git for Windows 2.22:
Start Pageant (C:\Program Files\PuTTY\pageant.exe) and Add key.
Start the ssh agent shim (C:\Program Files\Git\cmd\start-ssh-pageant.cmd). This takes care of the communication between Git ssh, which looks for ssh-agent, and Pageant.
Create the SSH_AUTH_SOCK environment variable
Control Panel / System / Advanced Settings / Environment Variables..
User variables for username / New..:
Variable name: SSH_AUTH_SOCK
Variable value: /tmp/.ssh-pageant-username (e.g. /tmp/.ssh-pageant-bill) (Environment Variable assignment screenshot)
Test ssh:
Open a command prompt: Enter set to view the list of Environment Variables. Is the SSH_AUTH_SOCK variable set correctly to something like /tmp/.ssh-pageant-bill?
Try ssh to your host using Git's ssh.exe: c:\Program Files\Git\usr\bin\ssh.exe user#host If this works, then VS Code Remote-SSH should work.
Finally, I added Pageant and start-ssh-pageant.cmd to my Windows 7 Startup so this persists across reboots.
Hope that helps.
Jerry.
I had a similar problem trying to get VS Code Remote use Putty Pageant.
1. Create .bat file somewhere with the following content:
echo OpenSSH
"C:\YOUR_PATH_HERE\PLINK.EXE" -ssh %*
2. Open VS Code settings, type remote ssh path in search and find Remote.SSH: Path settings
3. Past here path to your .bat file
4. Now VS Code Remote will use Pageant correctly.

TFS Post Build script executing twice

I have a post build batch file being executed after a TFS build. It compiles an Inno Setup script and places the generated exe in a drop folder. It then tries to run that exe and install the application on the server. It runs the exe; however, this hangs the build.
The issue is, it seems to execute it twice. I can see 2 process running for the installer in task manager. If I execute the batch file manually, there are no issues - it's only when TFS executes it, I run into this problem.
Post Build Batch File
cd "C:\Program Files (x86)\Inno Setup 5"
iscc "%scriptDir%\Script.iss"
cd "C:\Deployment"
start Installer.exe /VERYSILENT
Any ideas would be greatly appreciated. Scratching my head with this.
From my findings, the post build script was NOT executing twice.
I believe the issue had something to do with permissions. The build service was being executed via the LocalService account which did not have permission to install the application. I THINK the build service tried to execute the installer but was denied and silently failed (and possibly tried again causing the additional installer process).
Solution: Set the Build Service to run under a different account with the permissions to install applications.

Batch script not doing anything when execute from remote machine using ssh

i'm having a problem while executing batch script from linux machine.
Scenario:
I've a windows machine installed server2008, I need to automate some windows task that executes from linux machine. I've installed cygwin software on windows VM and create a batch script that is running fine from cygwin terminal. i.e cd ~/;./script.bat
Problem:
When I execute the same script from linux machine using ssh it seems works fine and print script executed successfully but when I checked that the task from windows it did nothing.
cat script.bat
#echo off
set sourcePasswd=%1
set destinationPasswd=%2
set destinationProjectName=%3
set user=%4
set xmlPath=C:\cygwin\home\%user%\Duplicate.xml
ECHO Start : Duplication project source for %destinationProjectName%
"C:\Program Files (x86)\Common Files\MySoftware\Duplicate.EXE" -f %xmlPath% -sp %sourcePasswd% -dp %destinationPasswd% -sup -md -dn %destinationProjectName%
ECHO Finish : Duplication project source for %destinationProjectName%
Looks like Leopard hasn't been back since he posted the question or the link to the answer, so I'll be the Point Pimpette tonight and fill in the blank.
The answer below is from the link:
http://cygwin.com/ml/cygwin/2010-07/msg00598.html
It was fixed after doing the following setup :
Open control panel=> Administrative Tools=>Computer
Management=>Services
lookup the sshd service, right
click=>properties=>log on, and check the checkbox for Allow service
to interact with desktop
restart the service.
thanks
Saravana

Resources