Wednesday, April 15, 2015

How to kill installed windows service which is stuck at starting state

One day I have installed the windows service using developer command line tool. Service is installed successfully. After that I tried to start the service from command prompt, suddenly it got stuck at starting.

At that time, I thought to kill the process using command line because I cannot reboot the server.

Step 1: First of all you need to find the service name which has stuck at starting state

Navigate to Run >> type Services.msc

It will open the Services window, find the installed windows service which has stuck at starting state and click on it and note down the name of service.

Step 2: Now open the command prompt and type the below command

> sc queryex ServiceName

It will result as below and note down the PID.



Step 3: From command prompt type the below command to kill the service using PID

>taskkill /f /pid 11140


Enjoy SharePoint!!!

How to get image URL using JSOM in SharePoint 2013

Use below code to get the image URL from the Image field which has type as Hyperlink or Picture in SharePoint custom list.

var user;
var clientContext;
var lstItem;
SP.SOD.executeFunc('sp.js', 'SP.ClientContext', loadImage);

function loadImage() {
DisplayImage() ;
}
function DisplayImage () {

     clientContext = new SP.ClientContext();
     var groupCollection = clientContext.get_web().get_siteGroups();
     user = clientContext.get_web().get_currentUser();
     clientContext.load(user);
     clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
}

function onQuerySucceeded() {
var lst = clientContext.get_web().get_lists().getByTitle(“ListName”);
    var camlQuery = new SP.CamlQuery();
    camlQuery.set_viewXml('<View> <Query> <Where><Eq><FieldRef Name=\ID\' /><Value Type=\'Text\'>1</Value></Eq></Where> </Query> <ViewFields><FieldRef Name=\'Image\' /><FieldRef Name=\'ID\' /></ViewFields> </View>');
    lstItem= lst.getItems(camlQuery);
    clientContext.load(lstItem);
    clientContext.executeQueryAsync(onSuccess, onQueryFailed);
}
function onSuccess()
{
            var ListEnum = lstItem.getEnumerator();
           
            while(ListEnum.moveNext()){
                        var objListItem=ListEnum.get_current();
                        document.getElementById("ImageID").src= objListItem.get_item("Image").get_url();
                        }
}
function onQueryFailed(sender, args) {
    console.log('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}


Enjoy SharePoint!!!