虽然大多数普通用户可能无法理解创建特定大小的随机虚拟文件的需求,但极客、软件开发人员和高级用户知道为什么这些文件有时会派上用场。您可以使用虚拟文件来确定硬盘驱动器上是否有任何坏扇区,测试网络速度(network speed),或确保您的计算机或设备(computer or device)上的文件被删除而无法恢复。无论(Regardless)您出于何种原因,这里有四种方法可以在任何现代版本的 Windows 中创建此类文件:
1. 使用fsutil 命令(fsutil command)创建一个虚拟文件
自Vista(Vista)以来的所有Windows版本都包含一个名为fsutil.exe的可执行文件。在Windows 10中,您可以在"C:\Windows\System32"文件夹中找到它。
Fsutil.exe是用于管理分区和卷的强大工具。除此之外,您还可以使用它从命令提示符(Command Prompt)快速创建任意大小的虚拟文件。
启动命令提示符(Command Prompt)的方法有很多,但我们更喜欢在任务栏的搜索字段(search field)中输入“cmd”,然后单击或点击命令提示符(Command Prompt)。如果您打算在受保护的系统文件夹(system folder)(如您的C:驱动器)中创建随机虚拟文件,请改为按“以管理员身份运行”("Run as administrator")。
打开命令提示符(Command Prompt)后,输入fsutil并按Enter以查看此工具支持的命令列表。您可以使用许多参数。这只是让您了解fsutil.exe可以做什么。您可以在TechNet(TechNet)上的官方文档中找到有关其功能的完整信息。
您可以在命令提示符(Command Prompt)中输入两个命令来创建虚拟文件:
- fsutil 文件创建新文件名(filename) 大小(size)
- fsutil 文件创建新路径文件名大小(pathfilename size)
将文件名(filename)替换为您想要的虚拟文件(dummy file)名称。您可以选择是否添加扩展名,因为这不会影响流程。将size替换为您希望虚拟文件(dummy file)具有的大小。大小以字节为单位。使用在线转换器(an online converter)来帮助您定义您喜欢的尺寸可能会更容易。
这两个命令之间的区别在于,第二个命令允许您通过将路径(path)替换为您在设备上选择的位置来准确指定文件的存储位置。
现在我们已经完成了理论部分,让我们看看它在实践中是如何工作的。我们首先创建了一个名为myfile.exe的文件,其大小为 10MB 或 10485760 字节。要创建它,我们输入以下命令:fsutil file createnew myfile.exe 10485760
如上所示,如果您使用第一个命令并且未指定路径,则该文件将在您的用户配置文件文件夹(user profile folder)中创建。在我们的例子中,它存储在C:UsersDiana Ann Roe。然后,我们创建了另一个 2MB 的文件,这次使用的是特定路径且没有扩展名。我们输入:fsutil file createnew D:myfile 2097152
需要注意的一个方面是使用 fsutil.exe 创建的文件是空的。里面没有内容。
2.使用Dummy File Creator创建一个随机的虚拟文件(dummy file)
如果您想要包含随机内容(random content)的虚拟文件,或者您对命令提示符(Command Prompt)感到不舒服,那么您应该考虑使用第三方应用程序。一个免费且易于使用的工具是Dummy File Creator。
您可以在安装程序和存档之间进行选择。我们建议您获取存档并将其提取到计算机上的某个位置。然后,运行Dummy.exe文件。如果要在系统驱动器(system drive)( C :) 上生成文件,请右键单击或按住并选择“以管理员身份运行("Run as administrator)”,否则程序在尝试创建文件时会返回错误。
虽然需要改头换面,但该程序的界面很简单。模式(Mode)部分允许您选择是否要生成一个或多个文件。使用浏览(Browse)按钮到达您要创建文件的位置并输入名称(和扩展名,如果需要)。接下来,如果您希望文件具有随机内容,请指定文件大小(File Size)并选中“随机文件内容(不可压缩)”框。("Random file content (non-compressible)")然后,单击或点击(click or tap) 创建(Create)。
在创建文件时,进度条(progress bar)可让您随时了解最新情况。
程序完成编写后,您会收到一条通知,通知您文件已创建。
这个工具显然比fsutil.exe更容易使用,而且它还具有几个优点,比如同时创建更多文件和添加随机文件内容(file content)的选项。
3.使用磁盘工具(Disk Tools)创建一个随机虚拟文件(dummy file)
另一个提供更多自定义选项的免费替代品是磁盘工具工具包(Disk tools toolkit)。顾名思义,这是一套小型免费磁盘相关工具。这些工具之一是文件生成器(File Generator)。下载并运行CubicDesign_tools.exe。当您尝试访问它时,Windows Defender SmartScreen会弹出,告诉您它阻止了无法识别的应用程序启动。单击(Click)或点击更多信息(More info),然后选择仍然运行(Run anyway)。单击或点击安装(Install)并等待应用程序解压缩。提取完成后,文件资源管理器(File Explorer)会将您带到新创建的名为Tahionic 工具包的文件夹(Tahionic tools package). 在此套件中包含的所有文件中,从System & security文件夹中打开Disk Tools.exe 。
同样急需改造,磁盘工具(Disk Tools)在文件生成器(File generator)选项卡中打开,这是我们创建虚拟文件所需的选项卡。
此选项卡中的四个部分可帮助(tab help)您自定义虚拟文件(dummy file):
- 文件数(Number of files)- 设置生成文件的数量。
- 文件大小(File size)- 设置文件大小(file size)或选择右侧建议的大小之一。
- 文件名(File name)- 设置文件名和位置(file name and location)。选择Pattern以输入自定义名称(custom name)(以及可选的扩展名)
- 文件内容(File content)- 设置文件内容。选择“使用此内容填充文件”("Fill the files with this content")以自定义文件中的文本并解锁“使文件唯一("Make file unique)”选项,当您创建多个文件并且您不希望生成具有相同内容的文件时,该选项会派上用场。
完成设置后,单击或点击(click or tap) 创建(Create)。哔声表示虚拟文件(dummy file)已创建,并且在选项卡的底部,程序还会让您知道生成文件所花费的时间。程序可能会发出哔哔声并宣布它已生成虚拟文件(dummy file),但该文件不在指定位置。如果您在没有管理员权限的情况下运行磁盘工具(Disk Tools)并且尝试在系统驱动器(system drive)( C :) 上创建文件,则可能会发生这种情况。要在Windows 计算机或设备(Windows computer or device)上的任何位置创建文件,请确保以管理员身份打开程序。
我们喜欢这个应用程序的地方在于,虽然它看起来有点杂乱,但它提供了出色的配置选项,并且在文件内容方面你有发言权。生成唯一文件的选项也是一个不错的选择。
4.使用PowerShell创建一个随机虚拟文件(dummy file)
您还可以在Windows中使用PowerShell创建一个(PowerShell)虚拟文件(dummy file)。虽然我们在之前的教程中详细介绍了您可以打开此应用程序的所有方法,但我们发现在任务栏的搜索字段中键入(search field)“powershell”,然后单击或点击Windows PowerShell是最简单的方法。但是,如果您打算在系统驱动器(system drive)( C :) 上创建随机虚拟文件,请确保在打开它时从右侧的选项中选择“以管理员身份运行” 。("Run as Administrator")
PowerShell应用程序启动,等待您键入命令并运行它们。
要创建一个虚拟文件(dummy file),您需要输入以下一行命令:
$out = 新对象字节[]大小(size);(新对象随机(Random)).NextBytes($out); [IO.File]::WriteAllBytes(' pathfilename ', $out)
将size替换为您的虚拟文件应具有的大小(以字节为单位)。如果您需要帮助定义您喜欢的尺寸,您可以使用在线转换器。(an online converter)将路径(path)替换为您要创建虚拟文件(dummy file)的位置。将文件名(filename)替换为您想要的虚拟文件(dummy file)名称。如果需要,请添加文件扩展名,因为这对流程没有影响。(file extension)让我们用一个例子来说明这一点,以使其更清楚:
我们决定在D:分区上创建一个大小为 1MB(或 1048576 字节)的名为mypowerfile.txt的文件。(mypowerfile.txt)要创建它,我们输入以下命令:$out = new-object byte[] 1048576; (new-object Random).NextBytes($out); [IO.File]::WriteAllBytes('D:mypowerfile.txt', $out)(new-object Random).NextBytes($out); [IO.File]::WriteAllBytes('D:mypowerfile.txt', $out)
尽管PowerShell不提供实时反馈(除非您在编写命令时出错),但与我们讨论的其他应用程序一样,您可以在准备好执行另一个命令时告诉它已完成创建文件。如果你去指定的位置,你可以看到已经创建了虚拟文件。(dummy file)
与在命令提示符(Command Prompt)中使用fsutil类似,您可以省略路径(path),并在您的用户配置文件文件夹(user profile folder)中创建文件。我们使用与上面相同的命令,完全省略了路径(path):$out = new-object byte[] 1048576; (new-object Random).NextBytes($out); [IO.File]::WriteAllBytes('mypowerfile.txt', $out)(new-object Random).NextBytes($out); [IO.File]::WriteAllBytes('mypowerfile.txt', $out)
如果没有路径,新的虚拟文件(dummy file)默认存储在C:UsersYourUserNamemypowerfile.exe中,如下所示。与fsutil 不同(fsutil),PowerShell允许您创建具有随机内容的虚拟文件。如果您比较使用相同命令创建的两个文件,您可以看到它们具有不同的内容。
在上述所有选项中,PowerShell是最复杂的,因为它的命令很复杂,而且在生成虚拟文件(dummy file)时没有确认。但是,与其他选项相比,高级用户可能更喜欢它。
提示:(TIP:)使用上面的PowerShell命令时,您可以添加一个参数,使控制台提供反馈(provide feedback),同时创建虚拟文件。但是,请记住,这会使命令不必要地长,因为您必须插入以下单行:
$out = new-object byte[] 1048576; (new-object Random).NextBytes($out); [IO.File]::WriteAllBytes('mypowerfile.txt', $out); if ($out -ne $null) {Write-Host ("Dummy file successfully created")} else {"Failed to create dummy file"}
你觉得哪种方法最简单?
为了给大家带来这个教程,我们搜了网上的坑,下载了太多可疑文件。在关闭它之前,请告诉我们您更喜欢哪种方法?此外,如果您知道在Windows(Windows)中创建虚拟文件的其他方法,请不要犹豫,在下面的评论中分享它们,我们承诺会检查它们。
4 ways to create random dummy files with a specific size in Windows
While most regular usеrs might have issueѕ understanding the need to create randоm dummy files of a specifіc size, geeks, software developers, and power users know why suсh files can come in handу somеtimes. You can use dummy files to figure out if there are any bad sectors on your hard drive, to test network speed, or to ensure thаt files on your computer or device are deleted beyond recovery. Regardleѕs of your reasons, here are four ways to create such files in any modern vеrsion of Windows:
1. Create a dummy file with the fsutil command
All Windows versions since Vista include an executable named fsutil.exe. In Windows 10, you can find it in the "C:\Windows\System32" folder.
Fsutil.exe is a powerful tool for managing partitions and volumes. Among many other things, you can also use it to quickly create dummy files of any size from the Command Prompt.
There are a lot of ways to launch the Command Prompt, but we prefer to enter "cmd" in our taskbar's search field, and then to click or tap on Command Prompt. If you intend to create random dummy files in a protected system folder (like your C: drive), press "Run as administrator" instead.
Once the Command Prompt is open, type in fsutil and hit Enter to see a list of commands supported by this tool. There are many parameters that you can use. This only gives you a taste of what fsutil.exe can do. You can find complete information about its capabilities in its official documentation on TechNet.
There are two commands you can enter in the Command Prompt to create a dummy file:
- fsutil file createnew filename size
- fsutil file createnew pathfilename size
Replace filename with the name you want for the dummy file. You can choose to add an extension or not, as this does not affect the process. Replace size with the size you want your dummy file to have. The size is measured in bytes. It might be easier to use an online converter to help you define the size you prefer.
The difference between the two commands is that the second one allows you to specify exactly where your file is stored, by replacing path with a location of your choice on your device.
Now that we got over the theory part, let's see how this works in practice. We first created a file called myfile.exe with a size of 10MB or 10485760 bytes. To create it, we entered the following command: fsutil file createnew myfile.exe 10485760
As seen above, if you use the first command and do not specify a path, the file is created in your user profile folder. In our case, it was stored at C:UsersDiana Ann Roe. We then created another 2MB file, this time using a specific path and no extension. We entered: fsutil file createnew D:myfile 2097152
One aspect to note is that the files created with fsutil.exe are empty. There's no content inside.
2. Create a random dummy file with Dummy File Creator
If you want dummy files with random content, or if you are uncomfortable with the Command Prompt, then you should consider using third-party apps. A free and easy to use tool is the Dummy File Creator.
You can choose between the installer and an archive. We recommend you to get the archive and extract it somewhere on your computer. Then, run the Dummy.exe file. If you want to generate files on your system drive (C:), right-click or press-and-hold and select "Run as administrator," or the program returns an error when it tries to create your files.
While in need of a makeover, the interface of this program is straightforward. The Mode section lets you choose whether you want to generate one file or more. Use the Browse button to get to the location where you want to create the file(s) and type in the name (and extension, if you want one). Next, specify the File Size and check the "Random file content (non-compressible)" box if you want your file(s) to have random content. Then, click or tap Create.
A progress bar keeps you updated while your file is being created.
As soon as the program finishes writing, you get a notification informing you that your file was created.
This tool is obviously easier to use than fsutil.exe, and it also comes with several advantages, like creating more files at the same time and the option to add random file content.
3. Create a random dummy file with Disk Tools
Another free alternative that provides more customization options is the Disk tools toolkit. As the name implies, this is a suite of small free disk-related tools. One of these tools is the File Generator. Download and run CubicDesign_tools.exe. When you try to access it, Windows Defender SmartScreen pops up, telling you that it prevented an unrecognized app from starting. Click or tap on More info and choose Run anyway. Click or tap Install and wait for the app to unpack. Once the extraction is complete, File Explorer takes you to the newly created folder called Tahionic tools package. Out of all the files included in this suite, open Disk Tools.exe, from the System & security folder.
Also in dire need of a makeover, the Disk Tools opens at the File generator tab, which is the one we need to create dummy files.
The four sections in this tab help you customize your dummy file(s):
- Number of files - Set the number of generated files.
- File size - Set the file size or choose one of the suggested sizes on the right.
- File name - Set the file name and location. Select Pattern to enter a custom name (and, optionally, an extension)
- File content - Set the file content. Select "Fill the files with this content" to customize the text in your file and to unlock the option to "Make file unique," which comes in handy when you create multiple files, and you don't want generated files with identical content.
When you are done setting things up, click or tap Create. A beep signals that the dummy file was created, and, at the bottom of the tab, the program also lets you know the time it took to generate the file. It is possible for the program to beep and announce it has generated the dummy file, but the file is not at the specified location. This can happen if you are running Disk Tools without administrator permissions and you are trying to create files on your system drive (C:). To create files anywhere on your Windows computer or device, make sure to open the program as administrator.
What we liked about this app is that, although it looks a bit cluttered, it provides excellent configuration options, and you have a say when it comes to file content. The option to generate unique files is also a nice touch.
4. Create a random dummy file with PowerShell
You can also create a dummy file using PowerShell from Windows. While we detailed all the ways you can open this app in a previous tutorial, we find it easiest to type in "powershell" in the taskbar's search field, and then to click or tap on Windows PowerShell. However, if you plan to create random dummy files on your system drive (C:), make sure to select "Run as Administrator" from the options on the right when you open it.
The PowerShell app launches, waiting for you to type commands and run them.
To create a dummy file, you need to enter the following one-line command:
$out = new-object byte[] size; (new-object Random).NextBytes($out); [IO.File]::WriteAllBytes('pathfilename', $out)
Replace size with the size your dummy file should have, in bytes. You can use an online converter if you need help defining the size you prefer. Replace path with the location where you want to create the dummy file. Replace filename with the name you want for the dummy file. Add a file extension if you want to, as this has no impact on the process. Let's illustrate this with an example to make it clearer:
We decided to create a file called mypowerfile.txt with a size of 1MB (or 1048576 bytes) on the D: partition. To create it, we entered the following command: $out = new-object byte[] 1048576; (new-object Random).NextBytes($out); [IO.File]::WriteAllBytes('D:mypowerfile.txt', $out)
Although PowerShell does not offer real-time feedback (unless you made an error writing the command), like the other apps we went over, you can tell it is done creating the file when it is ready for another command. If you go to the specified location, you can see that the dummy file has been created.
Similar to using fsutil in the Command Prompt, you can leave out the path and the file is created in your user profile folder. We used the same command as above, leaving out the path entirely: $out = new-object byte[] 1048576; (new-object Random).NextBytes($out); [IO.File]::WriteAllBytes('mypowerfile.txt', $out)
Without a path, the new dummy file is stored by default at C:UsersYourUserNamemypowerfile.exe, as seen below. As opposed to fsutil, PowerShell lets you create dummy files with random content. If you compare two files, created using the same command, you can see that they have different content.
Out of all the options above, PowerShell is the most complicated, both because of the complexity of its commands and the absence of confirmation when your dummy file is generated. However, power users might prefer it to the other options.
TIP: When using the PowerShell commands above, you can add a parameter that makes the console provide feedback, while creating dummy files. However, keep in mind that this makes the command unnecessarily long, as you have to insert the following one-liner:
$out = new-object byte[] 1048576; (new-object Random).NextBytes($out); [IO.File]::WriteAllBytes('mypowerfile.txt', $out); if ($out -ne $null) {Write-Host ("Dummy file successfully created")} else {"Failed to create dummy file"}
Which method do you find easiest?
We searched the pits of the internet and downloaded one too many suspicious files in order to bring you this tutorial. Before you close it, please let us know which of these methods do you prefer? Also, if you know other ways to create dummy files in Windows, don't hesitate to share them in the comments below and we promise to check them out.