I already mentioned the problem in another thread, but I thought the root of the error was another. Now I know the real error, but cannot solve it, and don't understand it.
I want to install Visual Studio Test Controller on an Azure instance. I am trying to do that via a startup task, that runs a batch-file which in turn downloads the test controller installation file and installs it on the instance.
The problem is: that does not work when running the installation via startup task. When I log in to the machine via RDP and double click the exact same batch file everything works fine.
Here are some additional information:
This is my batch file I execute:
powershell $command = "set-executionpolicy Unrestricted"
powershell $command = ".\setupController.ps1" -NonInteractive >; out.txt
echo Setup TestController >> %~dp0out.txt
cd E:\approot
timeout /T 60
"E:\approot\testcontroller.exe" /full /q /Log %~dp0install.log
echo Setup has been executed! >> %~dp0out.txt
net user vstestagent MyPassword! /add
net localgroup Administrators vstestagent /add
REM Create a task that will run with full network privileges.
net start Schedule
schtasks /CREATE /TN "Configure Test Controller Service" /SC ONCE /SD 01/01/2020 /ST 00:00:00 /RL HIGHEST /RU vstestagent /RP MyPassword! /TR e:\approot\configcontroller.cmd /F
schtasks /RUN /TN "Configure Test Controller Service"
This is the startup task of the role:
<Task executionContext="elevated" taskType="background" commandLine="setupController.cmd"></Task>
The batch file, as well as the installation file of Test Controller are located in E:\approot folder
The installation logfile of testcontroller says something like that:
0A88:0ABC][2013-04-12T10:36:04]: Creating a system restore point.
[0A88:0ABC][2013-04-12T10:36:04]: System restore disabled, system restore point not created.
[0A88:0ABC][2013-04-12T10:36:04]: Caching bundle from: 'C:\Resources\temp\48c0ec5daf5846cab7f53f6b5c80dc6f.TestController\RoleTemp\{44f19fb6-98e0-4462-886c-c5e56d82dfd3}\.be\vstf_testcontroller.exe' to: 'D:\ProgramData\Package Cache\{44f19fb6-98e0-4462-886c-c5e56d82dfd3}\vstf_testcontroller.exe'
[0A88:0ABC][2013-04-12T10:36:04]: Registering bundle dependency provider: {44f19fb6-98e0-4462-886c-c5e56d82dfd3}, version:
11.0.51106.1
[0A40:09EC][2013-04-12T10:36:04]: MUX: Cache Begin
[0A40:064C][2013-04-12T10:36:05]: Error 0x80070070: Failed to set end of file.
[0A40:064C][2013-04-12T10:36:05]: Error 0x80070070: Failed to extract all files from container.
[0A40:09EC][2013-04-12T10:36:05]: Error 0x80070070: Faild to begin and wait for operation.
[0A40:09EC][2013-04-12T10:36:05]: Error 0x80070070: Failed to extract payload: a25 from container: WixAttachedContainer
[0A40:09EC][2013-04-12T10:36:05]: Failed to extract payloads from container: WixAttachedContainer to working path: E:\approot\testcontroller.exe, error: 0x80070070.
[0A40:0B98][2013-04-12T10:36:05]: Error 0x80070070: Failed while caching, aborting execution.
[0A88:0ABC][2013-04-12T10:36:05]: Removed bundle dependency provider: {44f19fb6-98e0-4462-886c-c5e56d82dfd3}
... Some Rollback and cleanup
[0A40:0B98][2013-04-12T10:36:06]: Variable: WixBundleTag = vstf_testcontroller,1031
[0A40:0B98][2013-04-12T10:36:06]: Variable: WixBundleVersion = 11.0.51106.1
[0A40:0B98][2013-04-12T10:36:06]: Exit code: 0x643, restarting: No
I really don't know where the problem is - especially because when I run the batch file via RDP everything works just fine.
The only difference seems to be the user esecuting the batch: Startup Tasks run with administrative priviledges and I think my RDP account is another, but also has administrative priviledges....
Best regards
Sebastian
I still don't know WHY it is that way, but the installation works, if you do it via a scheduled task.
Because I thought the only difference is maybe the account installing the software, I first tried to install the test controller via runas command, but I could not pass a password along with the command. So I created a scheduled task for installing the test controller and was able to pass user credentials along with the command. Now my setupController.cmd looks like this:
powershell $command = "set-executionpolicy Unrestricted"
powershell $command = ".\setupController.ps1" -NonInteractive >; out.txt
echo Setup TestController >> %~dp0out.txt
cd E:\approot
echo Setup has been executed! >> %~dp0out.txt
net user vstestagent MyPassword! /add
net localgroup Administrators vstestagent /add
REM Create a task that will run with full network privileges.
net start Schedule
schtasks /CREATE /TN "Install Test Controller Service" /SC ONCE /SD 01/01/2020 /ST 00:00:00 /RL HIGHEST /RU vstestagent /RP MyPassword! /TR "E:\approot\testcontroller.exe /full /q /Log %~dp0install.log" /F
schtasks /RUN /TN "Install Test Controller Service"
timeout /T 120
schtasks /CREATE /TN "Configure Test Controller Service" /SC ONCE /SD 01/01/2020 /ST 00:00:00 /RL HIGHEST /RU vstestagent /RP MyPassword! /TR e:\approot\configcontroller.cmd /F
schtasks /RUN /TN "Configure Test Controller Service"
Hope it helps somebody else also.
Related
I am installing SQL Server Express 2017 using the command line. Once the install is done I use a batch file to create a database. The database creation fails giving a message that : login with 'sa' failed, The server is in single user mode
I have used the installation syntax given on the msdn website and my DB creation script is a batch file which creates a DB after confirming that SQL 2017 is installed. I am logging the errors in a file which gives me the single mode error information. Below is the installation statement I am using through cmd
SETUP.exe /q /ACTION=Install /BROWSERSVCSTARTUPTYPE=Automatic /SQLSVCSTARTUPTYPE=Automatic /FEATURES=SQL /INSTANCENAME=SQLEXPRESS /SQLSVCACCOUNT="NT AUTHORITY\Network Service" /SQLSYSADMINACCOUNTS="BUILTIN\ADMINISTRATORS" /AGTSVCACCOUNT="NT AUTHORITY\Network Service" /SQLSVCINSTANTFILEINIT="True" /IACCEPTSQLSERVERLICENSETERMS /SAPWD=<Password> /SECURITYMODE=SQL
The code to install the DB is :
%OSQLEXE% -S %SERVER% -U %USERNAME% -P %PASSWORD% -i "%AgentPath%\CreateDatabase.sql" >> c:\InstallLog.txt
Ideally my DB should be created but for some reason I get this error. Can someone please help?
I am trying to execute following PowerShell query in SQL Server
xp_cmdshell "get-WmiObject Win32_LogicalDisk -AV-RISCVMSQL114 | Format-Table -Property DeviceID,FreeSpace,Size"
After executing this, I am getting error:
'get-WmiObject' is not recognized as an internal or external command,
operable program or batch file.
I want to execute this command in all SQL Servers. It's getting executed on SQL Server 2008, but on SQL Server 2012, it's throwing that error due to version or some PowerShell component is not installed.
Can you to please look at the code and let me know
Try:
xp_cmdshell 'PowerShell.exe -noprofile -command "get-WmiObject Win32_LogicalDisk -AV-RISCVMSQL114 | Format-Table -Property DeviceID,FreeSpace,Size"'
If this doesn't work logon to the server open PowerShell with administrator rights. Type Get-ExecutionPolicy and check that Execution Policy is set to Unrestricted. If it isn't then enter the following, then type 'A' (Yes to All):
Set-ExecutionPolicy Unrestricted
If this still doesn't work try upgrading to at least PowerShell V3. But if this is not possible you can try repair your corrupt PowerShell V2 WMI repository with:
winmgmt /verifyrepository
If repository is found to be inconsistent run Winmgmt /salvagerepository and Winmgmt /resetrepository and verify after each. If it is still inconsistent try the following steps:
Go to Task Manager>> Services >> Open Service >> Windows Management Instrumentation service, and change the start up type to Manual.
Stop the WMI service:
net stop winmgmt
Rename the repository folder (C:\Windows\System32\wbem\Repository) to some else 'Repository_OLD'.
Start the WMI service:
net start winmgmt
Set the service back to auto start.
Failing Re-register all of the dlls and recompile the .mofs in the Wbem directory with the following .bat script and then reboot.
#echo off
sc config winmgmt start= disabled
net stop winmgmt /y
%systemdrive%
cd %windir%\system32\wbem
for /f %%s in (‘dir /b *.dll’) do regsvr32 /s %%s
wmiprvse /regserver
winmgmt /regserver
sc config winmgmt start= auto
net start winmgmt
for /f %%s in (‘dir /s /b *.mof *.mfl’) do mofcomp %%s
I found a way to uninstall IE 10 using a batch file which below and it works great like it's suppose to. It uninstalls and restarts the computer after about a minute.
FORFILES /P %WINDIR%\servicing\Packages /M Microsoft-Windows-InternetExplorer-10..mum /c "cmd /c echo Uninstalling package #fname && start /w pkgmgr /up:#fname /norestart /quiet"
shutdown -r
But I wanted to take this further and Hide IE 10 from windows updates which will prevent windows to install this update actually in the future and to do that, Microsoft provides an executable file which you can download from here
http://www.microsoft.com/en-us/download/details.aspx?id=36512 After extracting this executable, you get 3 files, IE10_Blocker.adm, IE_blocker.cmd and IE10_BlockerHelp.htm and Microsoft instructions are "In the Command Prompt, goto the folder where you have extracted these 3 files and type “ie9_blocker.cmd /B” and hit Enter to set the blocker on the machine."
I decided to make one batch file for all this so right now I got this far.
FORFILES /P %WINDIR%\servicing\Packages /M Microsoft-Windows-InternetExplorer-10..mum /c "cmd /c echo Uninstalling package #fname && start /w pkgmgr /up:#fname /norestart /quiet"
mkdir “C:\IE10”
copy /Y \file01p\Users\test\public\IE Update blocker\IE10*.* “C:\IE10”
start /d C:IE10\IE10_Blocker.cmd /b
shutdown -r
mkdir “C:\IE10” This command is suppose to create the directory called IE10 on C drive
copy /Y \file01p\Users\test\public\IE Update blocker\IE10*.* “C:\IE10” This command will copy those executable from the network public folders to their C:\IE10 which I just created in the previous step.
This script doesn't work. Only up to uninstalling IE 10 it works but it doesn't create the directory and so it doesn't copy the files from the network. How can do this?
Thanks
Thanks
Try running your batch as administrator.
in an administrator : command prompt it makes the directory without issue.
also, it could be that you do not have access to make the directory on C:
you could try locating it elsewhere that you are sure you have write access.
I am using psexec(with MSbuild Script) to run an xCopy on a server from Jenkins(Hudson). The command runs ok when run through Command Prompt(as System user), but gives the following error when tried using Jenkins. This is the command I am using from Msbuild script:
psexec \\<RemoteMachine> /accepteula -i -u <Domian\User> -p <Pass> -s cmd /c xcopy <Path1> <Path2> /e /i
PsExec v1.98 - Execute processes remotely
Copyright (C) 2001-2010 Mark Russinovich
Sysinternals - www.sysinternals.com
The handle is invalid.
Connecting to ..
Couldn't access :
Connecting to ...
**error MSB3073: The command "psexec \\<RemoteMachine> /accepteula -i -u <Domian\User> -p <Pass> -s cmd /c xcopy <Path1> <Path2> /e /i " exited with code 6.**
I have tried too many options but no luck so far.
Does anyone tried the same using Jenkins? Help will be really appreciated.
Are there any other ways to achieve this using some other tools without any problem. Please share.
Just wanted to post the solution here, as I figured it after some time.
The Remote Machine should have this user added in the Administrators Group.
This will resolve the connection issue. :)
I created a custom windows service in Visual Basic using Visual Studios '05.
The service is on our server which is running Windows Server 2003. I have installed the service, and it runs perfectly when I go into Computer Management and Start the service manually.
I have created a batch file to start the service using the NET START command. Whenever I run the batch file, the service doesn't start. I get this message from the command prompt:
The 'Service Name' is starting.
The 'Service Name' could not be started. The service did not report an error. More help is available by typing NET HELPMSG 3543.
I'm not sure what to do. (Been "googling" for a couple of hours.) It starts up when I manually run it, but it wont start via the batch file. Thanks!
Try forcing it to elevate in the batch file.
#ECHO OFF
:: Automatically elevate...
#ECHO OFF
SETLOCAL
:: Check if script was run with administrator privilages
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
:: If the error flag is set, we do not have admin.
IF "%ERRORLEVEL%"=="0" GOTO GOTADMIN
:UACPROMPT
ECHO. Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
ECHO. UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%\getadmin.vbs"
"%TEMP%\getadmin.vbs"
EXIT /B
:GOTADMIN
if exist "%temp%\getadmin.vbs" ( del "%temp%\getadmin.vbs" )
CD /D "%~dp0"
ENDLOCAL
GOTO SCRIPTSTART
:: THE ACTUAL SCRIPT STARTS HERE
:SCRIPTSTART
NET START [whatever service]