0
我一直在製作可寫入舊文本文件的批處理腳本時遇到問題。當我嘗試與舊文本文件來運行它,它說:「訪問被拒絕」(所以當我試圖把任何文本到現有文件)批處理 - 訪問使用批處理文本文件時「訪問被拒絕」
反正這裏是代碼:
@echo off
title file editor/creator
set lineNR=0
:start
set /p ANS= Do you want to access a 1:"old file" or 2"create a new" [1/2]
if %ANS% EQU 1 (goto old
) ELSE if %ANS% EQU 2 (goto new
) ElSE (echo invalid input & goto start)
:old
set /p name = what is the name of the file
set /p ending = what type of file is it
goto loop
:new
set /p name= what do you want the name of the file to be
set /p ending= what type of file do you want the file to be
echo %name%.%ending%
:Q1
set /p echo_off= do you want echo to be off? [y/n]
if %echo_off% EQU y (
echo @echo off >%name%.%ending%
goto loop
) ELSE IF %echo_off% EQU n (
goto loop
) ELSE (
goto Q1
)
:loop
echo press CTRL+LSHIF+C to end loop
goto loop1
:loop1
set /a lineNR=%lineNR% + 1
set /p line= %lineNR%:
echo %line% >>%name%.%ending%
// this is where it says that access is denied
goto loop1
'set a = b'生成一個名爲'a'的變量(注意空格!),其值爲「b」(注意空格!)。刪除等號 – SteveFest
之間的空格另請參閱[此MS支持](https://support.microsoft.com/zh-cn/help/250494/-access-is-denied-error-message-appears-when-permissions - 是正確的)有關您的問題的更多信息 – SteveFest
感謝這工作; 3 –