PsExec Access Denied Problem Solution

when we try to run remote programs from local system this error saying “Access Denied” may come. To overcome this, you have to add a registry key.

  1. Open RegEdit on your remote server
  2. Navigate to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System
  3. Add a new DWORD value called LocalAccountTokenFilterPolicy
  4. Set its value to 1
  5. Reboot your remove server
  6. Try running PSExec again from your local server

You should be able to execute remote commands.

Validators in QT

Validators are the input restriction filters we can apply up on our input fields like QLineEdit. We can make validators and apply to them so that they can be made to accept only numbers, capital letters, etc..

QT have some predefined validators. Eg for int,Regular expression etc.

We can create our own validators by subclassing QValidator class.

Example: Validator for Digits 0-9

#include “QValidator.h”

//Derive from Qvalidator
class DigitValidator:public QValidator

    //Validation function. Pure virtual in QValidator
    inline State validate( QString & input, int & pos ) const

        //Create a regular expression for the condition
        QRegExp vRX;

       //Search for it in the input
            return QValidator::Invalid;
            return QValidator::Acceptable;

void main()
    QLineEdit *txtInPut;
    txtInPut->setValidator(new DigitValidator);

Now the txtInPut line edit  box will only accept the input if its 0-9 other characters cant be entered.

Using TinyXML2 for XML Parsing in C++

I was searching for a easy,fast and small XML Parser for my project when I came across TinyXML2. I tried it and found that its indeed an easy and clean little parser which can cater to my need excellently.

Now lets see how it works.

Setting Up

You can get it from :

Just download it and build the files using the solution available in the folder. Then you will get Object file(tinyxml.obj) in “tinyxml2-master\tinyxml2\Win32\Release” or “tinyxml2-master\tinyxml2\Win32\Debug” depends up on which configuration you built.

You will have to link the object file in your project settings or else you will get “Unresolved external symbol errors”.

Include “tinyxml2.h” in your C++ file.

Now we are ready to Tackle XMLs.

Load and Parse XML File

Create a XMLDocument Object and call LoadFile() function. Give the file path as its parameter.

XMLDocument xmlDoc;


Parse XML formatted string

If you have a string which contains an XML, You can parse that using XMLDocument’s parse function.

XMLDocument dxml;

//Parse the xml sxml 
int rslt = dxml.Parse(sxml.c_str());

Getting root node

You can get the root node by calling FirstChild function of XMLDocument. It will return a pointer to the XMLNode class

XMLNode *rootnode = dxml.FirstChild();

Iterating Sibling Nodes

Then to iterate the nodes in the same level call NextSibling() function of XMLNode

XMLNode SiblingNode = rootnode ->NextSibling();

Getting Child Node

To get down to the child level nodes of current node call FirstChild() function of XMLNode

ChildNode = SiblingNode ->FirstChild();

Getting Data from Nodes

To get data from nodes we need to get the xml element from the Node. XMLNode class provides ToElement() function for this operation.

XMLElement *ChildElmt = ChildNode->ToElement();

Then we can get the Tag name of the Node using Name() function of XMLElement class.

string strTagName = ChildElmt ->Name();

We can get the values of the attributes of elements using the Attribute() function by giving the attribute name as parameter.

string strAttr = ChildElmt ->Attribute("YourAttributeName");

I am using tinyxml for some time now. And I must say I love its simplicity..

why we use Virtual Destructor

A destructor is a member function of a class, which gets called when the object goes out of scope.  So we have to do  all clean ups and final steps of class destruction are to be done in destructor.

If a member function is virtual, then calling the function on an object always invokes the function as implemented by the class which is derived finally. If the method is not virtual, then the implementation corresponding to the compile-time type of the object pointer.


Class Base
Base(){cout<<”Base constructor”;}
~Base{cout<<”Base destructor”;}
Class Derived: public Base
Derived(){cout<<”Derived constructor”;}
~Derived{cout<<”Derived destructor”;}
void main()
Base *Obj = new Derived();
delete Obj;

The output will be


Base constructor
Derived constructor
Base destructor

From the output we can see that the derived class destructor is not getting evoked. This is where virtual function comes to our aid. If we make the base class destructor as virtual.

Class Base
    Base(){cout<<"Base constructor";}
    virtual ~Base{cout<<"Base destructor";}

We will get our desired output as

Base constructor
Derived constructor
Derived destructor
Base destructor