When I call a script in my gitlab-ci yml file, sometimes some characters within the call are skipped, such that the command cannot be executed anymore.
An example:
The call of
$ Scripts/build_all.bat Argument1 Argument2
results in:
Script/build_all.bat : The term 'Script/build_all.bat' 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.
As you can see, the shell omits the 's' in the path 'Scripts'.
I could post many other examples, where characters are omitted, it can happen at different locations in the call.
My environment:
Docker Windows with gitlab runner 13.10.3. The docker image is based on mcr.microsoft.com/windows/servercore:ltsc2019
I have seen some developers used alias command for there projects. Like rs to run rails server.
How to create that alias rs="rails server"?
where to config that?
Is it works for window?
Is need any specific ruby or rails version?
It's about shell and not about rails. You can create alias to all commands you want. Those aliases are created on your profile like ~/.bash_profile or ~/.zshrc for example. Then to use aliases you need to study about them on documentation of shell you are using. On Windows I think Powershell supports aliases.
You don't have to put that command into a file (unless you want it to persist into the next session. To test what will work for you just put it in your terminal:
alias rs="rails server"
Then type rs. If it works you need alias, if not continue reading for doskey macros.
Now for windows, if you are running cygwin or a linux virtual machine, you use ALIAS. If you are using the Windows shell you ise DOSKEY.
doskey alias_name="some command here"
alias alias_name="some command here"
If you are on windows or 8 it doesn't like files without extensions. To create a .bashrc file, create a .bashrc. (notice the trailing .) and Windows will remove the last dot.
I created a Windows service with Delphi for a client server application.
To install it I use
c:\Test\MyService.exe /install (or /uninstall)
This installs the service and in Windows services it lists with "MyService" name and empty description.
How to define a different name and insert a description (to be seen when running services.msc)?
Note:
I need this because on the same machine i need to install more times the same service (1 per database).
Currently the only workaround i foudn is to rename the service exe, but I'd prefer to find out the correct command line way to do it (since I do this from ShellExecute).
Update:
Somehow i'd look for something like (this is just for explanation reasons of course! - InstallService.exe is a name i just invented):
InstallService.exe c:\Test\MyService.exe /install /name='MyService1'
/description='This is my service for database 1'
but also a more compact version would be fine like:
c:\Test\MyService.exe /install /name='MyService1'
/description='This is my service for database 1'
Windows already ships with the utility that you need, namely sc create.
>sc create /?
DESCRIPTION:
Creates a service entry in the registry and Service Database.
USAGE:
sc create [service name] [binPath= ] ...
OPTIONS:
NOTE: The option name includes the equal sign.
A space is required between the equal sign and the value.
type=
(default = own)
start=
(default = demand)
error=
(default = normal)
binPath=
group=
tag=
depend=
obj=
(default = LocalSystem)
DisplayName=
password=
This will create the service and allow you to specify the name and display name.
To modify the description you need sc description:
>sc description /?
DESCRIPTION:
Sets the description string for a service.
USAGE:
sc description [service name] [description]
The other obvious option is to build command line parsing into your service. That's trivially easy to do. Simply assign handlers for the service's BeforeInstall and/or AfterInstall events and process the switches there.
I'm using Memcached-for-Windows, see:
http://blog.elijaa.org/index.php?post/2010/08/25/Memcached-1.4.5-for-Windows&similar
I've tried to use:
sc create "memcached" binPath="C:/memcached/mem
cached.exe" start=auto
but I can't create the Windows service, and no warning or error, just:
Creates a service entry in the registry and Service Database.
SYNTAX:
sc create [service name] [binPath= ] <option1> <option2>...
CREATE OPTIONS:
NOTE: The option name includes the equal sign.
type= <own|share|interact|kernel|filesys|rec>
(default = own)
start= <boot|system|auto|demand|disabled>
(default = demand)
error= <normal|severe|critical|ignore>
(default = normal)
binPath= <BinaryPathName>
group= <LoadOrderGroup>
tag= <yes|no>
depend= <Dependencies(separated by / (forward slash))>
obj= <AccountName|ObjectName>
(default = LocalSystem)
DisplayName= <display name>
password= <password>
To implement this, you can even execute a command line, which inturn creates a service.
First go to the path where the .exe file exists through command line.
C:\Users\sireesh.yarlagadda>memcached.exe -d install
After executing this line, you will be seeing a new service created for memcached
The reason you're getting an error is that there must be a space after the binPath= . This is a very annoying 'feature' of sc. Also you'd need a space after the start=.
sc create "memcached" binPath= "C:/memcached/memcached.exe" start= auto
The above command wouldn't give you the syntax error. However, I suspect memcached still won't run successfully as a service.
memcached isn't a native Windows Service so you must use a "service wrapper" program to add the missing functionality. Microsoft's free Srvany utility should do the trick but several commercial alternatives are also available.
(Note that some Windows ports of memcached support the "-d" flag to automatically install and manipulate memcached as a native Windows Service but that doesn't seem to be available in NorthScale's version...)
You can build Memcached on Windows.
http://vasil9v.tumblr.com/post/31921755331/compiling-memcached-on-cygwin-windows
I have a couple old services that I want to completely uninstall. How can I do this?
Use the SC command, like this (you need to be on a command prompt to execute the commands in this post):
SC STOP shortservicename
SC DELETE shortservicename
Note: You need to run the command prompt as an administrator, not just logged in as the administrator, but also with administrative rights. If you get errors above about not having the necessary access rights to stop and/or delete the service, run the command prompt as an administrator. You can do this by searching for the command prompt on your start menu and then right-clicking and selecting "Run as administrator". Note to PowerShell users: sc is aliased to set-content. So sc delete service will actually create a file called delete with the content service. To do this in Powershell, use sc.exe delete service instead
If you need to find the short service name of a service, use the following command to generate a text file containing a list of services and their statuses:
SC QUERY state= all >"C:\Service List.txt"
For a more concise list, execute this command:
SC QUERY state= all | FIND "_NAME"
The short service name will be listed just above the display name, like this:
SERVICE_NAME: MyService
DISPLAY_NAME: My Special Service
And thus to delete that service:
SC STOP MyService
SC DELETE MyService
Click Start | Run and type regedit in the Open: line. Click OK.
Navigate to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services
Scroll down the left pane, locate the service name, right click it and select Delete.
Reboot the system.
As described above I executed:
sc delete ServiceName
However this didn't work as I was executing it from PowerShell.
When using PowerShell you must specify the full path to sc.exe because PowerShell has a default alias for sc assigning it to Set-Content. Since it's a valid command it doesn't actually show an error message.
To resolve this I executed it as follows:
C:\Windows\System32\sc.exe delete ServiceName
Use services.msc or (Start > Control Panel > Administrative Tools > Services) to find the service in question. Double-click to see the service name and the path to the executable.
Check the exe version information for a clue as to the owner of the service, and use Add/Remove programs to do a clean uninstall if possible.
Failing that, from the command prompt:
sc stop servicexyz
sc delete servicexyz
No restart should be required.
SC DELETE "service name"
Run the command on cmd as Administrator otherwise you will get this error :-
openservice failed 5 access is denied
If you have Windows Vista or above please run this from a command prompt as Administrator:
sc delete [your service name as shown in service.msc e.g moneytransfer]
For example: sc delete moneytransfer
Delete the folder C:\Program Files\BBRTL\moneytransfer\
Find moneytransfer registry keys and delete them:
HKEY_CLASSES_ROOT\Installer\Products\
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall\
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\EventLog\
HKEY_LOCAL_MACHINE\System\CurrentControlSet002\Services\
HKEY_LOCAL_MACHINE\System\CurrentControlSet002\Services\EventLog\
HKEY_LOCAL_MACHINE\Software\Classes\Installer\Assemblies\ [remove .exe references]
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Installer\Folders
These steps have been tested on Windows XP, Windows 7, Windows Vista, Windows Server 2003, and Windows Server 2008.
We can do it in two different ways
Remove Windows Service via Registry
Its very easy to remove a service from registry if you know the right path. Here is how I did that:
Run Regedit or Regedt32
Go to the registry entry "HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services"
Look for the service that you want delete and delete it. You can look at the keys to know what files the service was using and delete them as well (if necessary).
Delete Windows Service via Command Window
Alternatively, you can also use command prompt and delete a service using following command:
sc delete
You can also create service by using following command
sc create "MorganTechService" binpath= "C:\Program Files\MorganTechSPace\myservice.exe"
Note: You may have to reboot the system to get the list updated in service manager.
If they are .NET created services you can use the installutil.exe with the /u switch
its in the .net framework folder like
C:\Windows\Microsoft.NET\Framework64\v2.0.50727
This did the job for me on Windows 10:
start the cmd.exe as admin
run SC DELETE "com.docker.service"
reinstall docker
Here is a vbs script that was passed down to me:
Set servicelist = GetObject("winmgmts:").InstancesOf ("Win32_Service")
for each service in servicelist
sname = lcase(service.name)
If sname = "NameOfMyService" Then
msgbox(sname)
service.delete ' the internal name of your service
end if
next
sc delete name
Before removing the service you should review the dependencies.
You can check it:
Open services.msc and find the service name, switch to the "Dependencies" tab.
Source: http://www.sysadmit.com/2016/03/windows-eliminar-un-servicio.html
You can use my small service list editor utility Service Manager
You can choose any service > Modify > Delete. Method works immediately, no reboot required.
Executable file: [Download]
Source code: [Download]
Blog post: [BlogLink]
Service editor class: WinServiceUtils.cs
For me my service that I created had to be uninstalled in Control Panel > Programs and Features