如何自动创建dxdiag.txt文件?(DirectX信息文本文件)

本文关键字:文件 DirectX 信息 文本 创建 dxdiag txt 何自动 | 更新日期: 2023-09-27 18:24:29

我有一个.BAT文件,我称之为:DxDiag.BAT这是内容:

:: 24.07.2013
:: Dxdiag Miner 1.1 by me .
:: Feel free to redistribute and/or modify the file at will, but it'd be nice if you were to give the author credit.
:: Turn off echoing commands to the console, set colour to light green.
@echo off
Color 0A
echo Dxdiag Miner v1.1
:: Check for dxdiag.exe, in case not found go to Dxdiag_Not_Found.
echo Checking for dxdiag.exe...
if not exist %systemroot%'system32'dxdiag.exe GOTO Dxdiag_Not_Found
echo Dxdiag.exe found.
:: Execute dxdiag.exe, pass the path to the file.
echo Creating dxdiag file, please stand by...
%systemroot%'system32'dxdiag.exe /t %USERPROFILE%'AppData'Local'testing'testing'SF_24-07-13'dxdiag.txt
echo Dxdiag file created under the name of "dxdiag.txt" at %USERPROFILE%'Desktop
:: Open the newly created file.
%USERPROFILE%'Desktop'dxdiag.txt
exit

:Dxdiag_Not_Found
echo Dxdiag.exe was not found. Please contact support for further help.
pause
exit

第一个问题是,我希望它直接在一个特定的目录中创建文本文件:

%systemroot%'system32'dxdiag.exe /t %USERPROFILE%'AppData'Local'testing'testing'SF_24-07-13'dxdiag.txt

问题是现在最后的目录是:SF_24-07-13但有时会是另一个日期,例如目录为:SF_28-07-13

那么,我如何在BAT文件中更改/设置它,以便每次都找到正确的目录呢?

我想在c#中做的是,windows中的每个用户,如果它的xp vista 7或8会点击一个按钮,它会运行BAT文件,并创建包含所有信息的dxdiag文本文件。

这就是我现在所做的,但它不起作用:

:: 13.08.2011
:: Dxdiag 
:: Feel free to redistribute and/or modify the file at will, but it'd be nice if you were to give the author credit.
:: Turn off echoing commands to the console, set colour to light green.
@echo off
Color 0A
echo Dxdiag Miner v1.1
:: Check for dxdiag.exe, in case not found go to Dxdiag_Not_Found.
echo Checking for dxdiag.exe...
if not exist %systemroot%'system32'dxdiag.exe GOTO Dxdiag_Not_Found
echo Dxdiag.exe found.
:: Execute dxdiag.exe, pass the path to the file.
echo Creating dxdiag file, please stand by...
echo off
set today=%date:~7,2%-%date:~4,2%-%date:~10,4%
echo %today%
%systemroot%'system32'dxdiag.exe /t %USERPROFILE%'AppData'Local'Diagnostic_Tool_Blue_Screen'Diagnostic Tool Blue Screen'SF_today'dxdiag.txt
echo Dxdiag file created under the name of "dxdiag.txt" at %USERPROFILE%'Desktop
:: Open the newly created file.
%USERPROFILE%'Desktop'dxdiag.txt
exit

:Dxdiag_Not_Found
echo Dxdiag.exe was not found. Please contact support for further help.
pause
exit

我添加的部分是:

echo off
set today=%date:~7,2%-%date:~4,2%-%date:~10,4%
echo %today%
%systemroot%'system32'dxdiag.exe /t %USERPROFILE%'AppData'Local'Diagnostic_Tool_Blue_Screen'Diagnostic Tool Blue Screen'SF_today'dxdiag.txt

我做了SF_today之前也试过SF_%今天%我之前添加SF_的原因是目录如下:

C:'Users'bout0_000'AppData'Local'Diagnostic_Tool_Blue_Screen'Diagnostic Tool Blue Screen'SF_24-07-13

我做错了什么?

如何自动创建dxdiag.txt文件?(DirectX信息文本文件)

这是一个Windows批处理脚本问题,要获取日期,可以使用以下命令

echo %date%

这将生成输出为2013年7月24日星期三,要将日期转换为您想要的格式,您可以使用

%date:~i,n%

其中i是子字符串的起始索引,n是要获取的字符数。例如%日期:~10,4%将获得2013年(年份为4位数)

全代码

echo off
set today=%date:~7,2%-%date:~4,2%-%date:~10,4%
echo %today%

这将得到今天的日期字符串,输出为2013年7月24日,然后可以将此字符串插入到脚本中。