Skip to content

Access Denied error on uninstall #18

@ffalcinelli

Description

@ffalcinelli

Seems like driver needs to be unregistered before uninstalling the binding.

SYS files are still in use by the Windows Kernel, and trying to remove them results in an Access Denied error (WinError 5).

Successfully uninstalled pydivert-2.0.0
Exception:
Traceback (most recent call last):
  File "c:\program files (x86)\python35-32\lib\shutil.py", line 381, in _rmtree_unsafe
    os.unlink(fullname)
PermissionError: [WinError 5] Accesso negato: 'C:\\Users\\fabio\\AppData\\Local\\Temp\\pip-1vd8riwq-uninstall\\program files (x86)\\python35-32\\lib\\site-packages\\pydivert\\windivert_dll\\windivert64.sys'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\program files (x86)\python35-32\lib\site-packages\pip\basecommand.py", line 215, in main
    status = self.run(options, args)
  File "c:\program files (x86)\python35-32\lib\site-packages\pip\commands\uninstall.py", line 76, in run
    requirement_set.uninstall(auto_confirm=options.yes)
  File "c:\program files (x86)\python35-32\lib\site-packages\pip\req\req_set.py", line 337, in uninstall
    req.commit_uninstall()
  File "c:\program files (x86)\python35-32\lib\site-packages\pip\req\req_install.py", line 755, in commit_uninstall
    self.uninstalled.commit()
  File "c:\program files (x86)\python35-32\lib\site-packages\pip\req\req_uninstall.py", line 142, in commit
    rmtree(self.save_dir)
  File "c:\program files (x86)\python35-32\lib\site-packages\pip\_vendor\retrying.py", line 49, in wrapped_f
    return Retrying(*dargs, **dkw).call(f, *args, **kw)
  File "c:\program files (x86)\python35-32\lib\site-packages\pip\_vendor\retrying.py", line 212, in call
    raise attempt.get()
  File "c:\program files (x86)\python35-32\lib\site-packages\pip\_vendor\retrying.py", line 247, in get
    six.reraise(self.value[0], self.value[1], self.value[2])
  File "c:\program files (x86)\python35-32\lib\site-packages\pip\_vendor\six.py", line 686, in reraise
    raise value
  File "c:\program files (x86)\python35-32\lib\site-packages\pip\_vendor\retrying.py", line 200, in call
    attempt = Attempt(fn(*args, **kwargs), attempt_number, False)
  File "c:\program files (x86)\python35-32\lib\site-packages\pip\utils\__init__.py", line 102, in rmtree
    onerror=rmtree_errorhandler)
  File "c:\program files (x86)\python35-32\lib\shutil.py", line 488, in rmtree
    return _rmtree_unsafe(path, onerror)
  File "c:\program files (x86)\python35-32\lib\shutil.py", line 378, in _rmtree_unsafe
    _rmtree_unsafe(fullname, onerror)
  File "c:\program files (x86)\python35-32\lib\shutil.py", line 378, in _rmtree_unsafe
    _rmtree_unsafe(fullname, onerror)
  File "c:\program files (x86)\python35-32\lib\shutil.py", line 378, in _rmtree_unsafe
    _rmtree_unsafe(fullname, onerror)
  File "c:\program files (x86)\python35-32\lib\shutil.py", line 378, in _rmtree_unsafe
    _rmtree_unsafe(fullname, onerror)
  File "c:\program files (x86)\python35-32\lib\shutil.py", line 378, in _rmtree_unsafe
    _rmtree_unsafe(fullname, onerror)
  File "c:\program files (x86)\python35-32\lib\shutil.py", line 378, in _rmtree_unsafe
    _rmtree_unsafe(fullname, onerror)
  File "c:\program files (x86)\python35-32\lib\shutil.py", line 383, in _rmtree_unsafe
    onerror(os.unlink, fullname, sys.exc_info())
  File "c:\program files (x86)\python35-32\lib\site-packages\pip\utils\__init__.py", line 114, in rmtree_errorhandler
    func(path)
PermissionError: [WinError 5] Accesso negato: 'C:\\Users\\fabio\\AppData\\Local\\Temp\\pip-1vd8riwq-uninstall\\program files (x86)\\python35-32\\lib\\site-packages\\pydivert\\windivert_dll\\windivert64.sys'

To delete those files, we must stop the service before using pip

sc stop WinDivert1.1

The WinDivert documentation states that is possible to remove SYS and DLL files and driver will be uninstalled at next reboot, or manually by typing

sc stop WinDivert1.1
sc delete WinDivert1.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions