I just made a very simple batch virus that runs itself and runs on startup. I want to test it because I want to send it to a YouTuber who films himself running these viruses on a Virtual Machine.

The question is, how can I make the Virtual Machine safe for running this without going to my actual computer? Also, since a VM uses RAM from the host PC, how to make it so that the RAM is un-affected by this virus?

(The Virus Runs itself 5 times and also copies itself to the users Documents Folder, Desktop, and other places creating a lot of lag.)

I have absolutely no intention of spreading the virus to the public.

  • 3
    Unless you accidentally wrote a VM escape vulnerability (which would probably be worth a good amount of money), or shared folders from your host computer to the VM, then you don't have anything to worry about. – Macil Oct 18 '17 at 22:19
  • 1
    You should know what it does because you wrote it! Did you write it to go to your actual computer? – user253751 Oct 19 '17 at 3:23

The default settings for most VMs will be sufficient for keeping everything isolated, that's what they're designed for.

The specific settings might be a little different depending on what software your're using, but here's a few things you can check in your VM's settings to keep your computer safe:

  • Disable file sharing, shared clipboard, and Drag'n Drop
  • Set a cap for memory and processor usage, and virtual hard drive size
  • Make sure your network settings are set to disconnected or NAT
  • Make sure all your serial and USB ports are disabled/ not shared
  • Check that printers and other wireless devices associated with your PC aren't shared
  • So will disconnectiing from the internet work? – user8798029 Oct 19 '17 at 13:20
  • @user8798029 Yes it will, but is 1: Not necessary if you're using NAT or an equivalent and, 2: probably fine to disable once you download the virus, assuming it isn't reliant on internet connection. – Echo Oct 19 '17 at 23:43

To prevent the virus from escaping the VM's virtualized hard disk, you'll need to make sure you don't connect the VM and host file systems (no "shared drives" or "shared files" or anything). You should also make sure the VM has not mapped any network drives with write access.

RAM usage is not a concern. The RAM a VM uses is dedicated to the VM by its host; that RAM is not used for anything except the VM for so long as the VM runs. When the VM stops running, the data that it put in RAM may remain there (or may get erased), but that's not harmful; initializing memory before usage (not assuming anything about its old value) is fully understood in software development, and indeed, many languages' compilers won't even let you access uninitialized memory.

Obviously, don't let the VM use all your machine's resources; set a limit on the RAM, CPU, virtual disk size, etc. that the VM can access so that it doesn't bring your host to its knees.


Yes, it is safe as long as you respect the following:

  • no shared peripherals/ports between host and guest
  • no shared services between host and guest (like file/print share)
  • no network connections between host and guest (remove NIC completely from guest if you don't need to use it)

If you do need network connection, you will have to isolate, firewall and monitor it; do not use the same VLAN/subnet as the host.

Memory is not a problem because the allocated towards VM memory amount is practically removed from host access. For the host, it is an unusable / reserved memory area and will not be accessed at all.

  • What if I use Utorrent on host machine, with antivirus software both on host and on guest, is it safe? – Bruno Vincent Jan 19 at 0:02
  • uTorrent can use encrypted traffic and can be set to use any port so yes, it's safe. – Overmind Jan 21 at 8:54

Not the answer you're looking for? Browse other questions tagged or ask your own question.