Searching faster for a file on the drive using Python
Since you are already requiring the filename to start with the correct drive name, your target will already look like a normal valid path. So you could at least check if what the user entered is actually the correct path, short-circuiting the whole search:
def search(drive, target):
    if os.path.isfile(target):
        return os.path.abspath(target)
    ...

You should also stop looking as soon as you have found your target and use the in keyword instead of manually checking all files yourself:
    ...
    for root, dirs, files in os.walk(r&quot;D:\\&quot;):
        if target in files:
            return os.path.abspath(os.path.join(root, target))

Other than that, I am afraid you are mostly out of luck. There are only two ways to quickly find something in a big pile of somethings:

You search through all somethings until you find the something you are looking for.
You have a datastructure, called an index, which tells you how to find each (or at least some, including hopefully the one something you are looking for) of the somethings.

In the Unix world there is the command line tool locate, which uses a periodically updated database of files to make finding files fast (as long as they are in that database). I am not sure what the equivalent Windows (command line) tool is, though you may find some solution here. You can then call that tool using subprocess.
Of yourse, if you need this search very often (twice is probably already often enough), you could also built such an index yourself, meaning you only have to check all files once:
from collections import defaultdict

INDEX = {}

def build_index(drive):
    index = defaultdict(set)
    for root, _, files in os.walk(drive):
        for file in files:
            index[file].add(root)
    return dict(index)

def search(drive, target):
    if drive not in INDEX:
        INDEX[drive] = build_index(drive)
    root = next(iter(INDEX[drive][target]))
    return os.path.abspath(os.path.join(root, target))

Note that this arbitrarily chooses one result if a file name appears multiple times, similarly to your code which chooses the last one encountered (with the order of processing arbitrarily defined). On my machine, for example, there are 8708 files called index.js and it is not clear which one you want. It might be a better interface to return all of them instead of one arbitrary one.