0

I'm doing a school project that requires me to write a virus, I wanted to make a virus that deletes files on a system, but when using

os.remove()

it requires me to already have a path, does anyone know how to get around this?

I've already tried

path = (r"C:\Users\%username%\Desktop")

but that doesn't help and just leads to a Windows can't find path specified problem

Some_dude
  • 139
  • 1
  • 8

1 Answers1

1

Use getpass:

import getpass
curuser = getpass.getuser()
# Current User name
path = "C:\Users\%s\..." % curuser
Chris
  • 29,127
  • 3
  • 28
  • 51
  • Special folders such as "Desktop" are easily relocatable by the user. For ways to get the current location using PyWin32 and ctypes, see my answers [here](https://stackoverflow.com/a/46391031/205580) and [here](https://stackoverflow.com/a/33181421/205580). – Eryk Sun Apr 19 '19 at 12:30