2016-03-25 67 views
4

嗨,給大家在stackoverflow!如何使用保留名稱刪除此類文件?

我正在尋找的解決方法,如何使用保留的名稱,刪除這種文件:

(nul, aux, com1, prn, etc...)

所以,我得到的輸出誤差:

的語法文件名稱,目錄或卷不正確。

@echo off 
echo hello world>\\?\"%temp%\nul:nul" 
pause 
more<"%temp%\nul:nul" 
pause 
set /p MyVar=<"\\?\%temp%\nul:nul" 
echo %MyVar% 
Pause 
Del "\\?\%temp%\nul:nul" /F 
pause 

我用這種伎倆來存儲下面 所以在這個代碼所示像密碼,我可以設置密碼進入這個文件也,從它讀,但我不能刪除它。

@echo off 
Title %~n0 with colors by Hackoo 
Mode 50,5 & Color 0E 
Setlocal EnableDelayedExpansion 
:CreatePassword 
Call :InputPassword "Please choose your password" pass1 
Call :InputPassword "Please confirm your password" pass2 
If !pass1!==!pass2! (Goto:Good) Else (Goto:Bad) 
::*********************************** 
:InputPassword 
Cls 
echo. 
echo. 
set "psCommand=powershell -Command "$pword = read-host '%1' -AsSecureString ;^
    $BSTR=[System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($pword);^
     [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($BSTR)"" 
     for /f "usebackq delims=" %%p in (`%psCommand%`) do set %2=%%p 
Goto :eof 
::***********************************  
:Good 
Cls 
echo. 
echo. 
Call :Color 0B "     Good password " 1 
TimeOut /T 2 /NoBreak>nul 
Call :Write_Info 
Call :Collect_Info 
echo Your password stored as : "!SavedPass!" without quotes 
pause 
Goto :Eof 
::*********************************** 
:Bad 
Cls 
echo. 
echo. 
Call :Color 0C "   Wrong password try again " 1     
TimeOut /T 2 /NoBreak>nul 
Goto :CreatePassword 
::*********************************** 
:Color 
for /F "delims=." %%a in ('"prompt $H. & for %%b in (1) do rem"') do set "BS=%%a" 
set nL=%3 
if not defined nL echo Requires third argument & Pause > nul & goto :Eof 
if %3 == 0 (
    <nul set /p ".=%BS%">%2 & Findstr /V /A:%1 /R "^$" %2 nul & Del %2 2>&1 
    goto :Eof 
) else if %3 == 1 (
    echo %BS%>%2 & Findstr /V /A:%1 /R "^$" %2 nul & Del %2 2>&1 
    goto :Eof 
) 
::*********************************** 
:Write_Info 
(echo !Pass2!)>\\?\"%temp%\nul:nul" 
Call :Color 0A "   Your password is set sucessfuly" 1 
::*********************************** 
:Collect_Info 
(set /P SavedPass=)<"\\?\%temp%\nul:nul" 
goto :eof 
::*********************************** 

回答

相關問題