Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Batch file 将CMD命令重定向到EXE文件_Batch File_Redirect_Cmd_Command_Internal - Fatal编程技术网

Batch file 将CMD命令重定向到EXE文件

Batch file 将CMD命令重定向到EXE文件,batch-file,redirect,cmd,command,internal,Batch File,Redirect,Cmd,Command,Internal,基本上,我已经创建了一个choice批处理,因为我经常更改它,所以我可以经常存档启动数据的内容,它工作得非常完美。但是,我面临的问题是,每次我使用高级BAT-to-EXE转换器将批处理从.BAT编译到.EXE时,“bcdedit”命令都无法工作,并且“未识别为内部或外部命令、可操作程序或批处理文件。” 现在,我做的第一件事是确保我的硬盘上是否有环境变量,并且看起来很好: 路径:%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\system32\Wbe

基本上,我已经创建了一个choice批处理,因为我经常更改它,所以我可以经常存档启动数据的内容,它工作得非常完美。但是,我面临的问题是,每次我使用高级BAT-to-EXE转换器将批处理从.BAT编译到.EXE时,“bcdedit”命令都无法工作,并且“未识别为内部或外部命令、可操作程序或批处理文件。” 现在,我做的第一件事是确保我的硬盘上是否有环境变量,并且看起来很好:

路径:%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\system32\Wbem;%SystemRoot%\system32\WindowsPowerShell\v1.0\;C:\Program Files(x86)\QuickTime\QTSystem\;C:\Program Files(x86)\Intel\OpenCL SDK\2.0\bin\x86;C:\Program Files(x86)\Intel\OpenCL SDK\2.0\bin\x64;C:\Users\Support\DOCUME~1\MYFILE~1\Programs\SYSTEM~1\DISKEE~1\

它拥有完美运行所需的所有变量,再加上一些外部变量,这是可以的,然后我想,也许我应该尝试直接在我的文件夹中进行,通过在另一个论坛上进行一些研究: 我做了一个单独的.BAT,我调用它,它似乎确实创建了一个单独的变量:

C:\Users\???\Documents\;C:\Windows\system32;C:\Windows;C:\Windows\system32\Wbem;C:\Windows\system32\WindowsPowerShell\v1.0\;C:\Program Files(x86)\QuickTime\QTSystem\;C:\Program Files(x86)\Intel\OpenCL SDK\2.0\bin\x64;C:\Program Files(x86)\Intel\OpenCL SDK\2.0\bin\x64;C:\Users\Support\Document\Document\1\MYFILE~1\Programs\SYSTEM~1\DISKEE~1”/f

但还是没用

我在另一张表格上读到:

person的解决方案是使用Create Process()创建一个程序,使用sysnative(System32)自动将他重定向到文件夹,但我在C#方面完全是初学者,CMD是我在编码方面最擅长的领域

请我请求您尽快帮助我,如果您有答案,请以最简单的方式说明原因。以下是我的脚本,以防万一:

    :START
echo.
echo Call apath.bat
echo.
echo.
echo (E) - Start Process.
echo (C) - Launch Part 2 Of Process.
echo (N) - Load NoDrives Manager.
echo (D) - Display Currect Account and Computer Information
echo (X) - Exit EDIM.
echo.
echo NOTE - It will not work if not started with Admin Privillages.
echo.
:Choice
set/p Option=Please enter your option: 
if '%Option%' == 'E' goto :Incognito
if '%Option%' == 'C' goto :Touch
if '%Option%' == 'N' goto :Manager
if '%Option%' == 'D' goto :Data
if '%Option%' == 'X' goto :Exit
echo.
echo.
echo Invalid Option - Please Reselect.
goto :Choice
:RetryE
Echo An Error was found!
set/p RetryE=Retry? Y/N: 
if '%RetryE%' == 'Y' goto :Incognito
if '%RetryE%' == 'N' goto :Exit
:Incognito
Timeout 5
echo.
echo.
echo.
Echo Saving OriginalBCD...
bcdedit /export "Data/BCD/OriginalBCD"
IF %ERRORLEVEL% GTR 0 goto :RetryE
IF %ERRORLEVEL% LSS 0 goto :RetryE
Echo Checking presence of BCD...
IF NOT EXIST "Data/BCD/OriginalBCD" goto :RetryE
Echo Deleting Boot Entry...
bcdedit /delete {current}
IF %ERRORLEVEL% GTR 0 goto :RetryE
IF %ERRORLEVEL% LSS 0 goto :RetryE
Echo Saving EditedBCD...
bcdedit /export "Data/BCD/IncogBCD"
IF %ERRORLEVEL% GTR 0 goto :RetryE
IF %ERRORLEVEL% LSS 0 goto :RetryE
Echo Checking presence of BCD...
IF NOT EXIST "Data/BCD/IncogBCD" goto :RetryE
Echo Allowing User Control For Assigning System Reserved Partitions...
Echo -Commands-
Echo Diskpart
Echo List volume
Echo Select Volume "" (The one that has no Letter and remember number)
Echo Assign Letter=Z
Echo Select Volume "" (The one that has Letter E and remember number)
Echo Remove Letter=E  (This is the new system reserved partition)
Echo Then exit Diskpart to finish Part 1.
Diskpart
Echo Ready To Restart!
Timeout 5
Shutdown /r /t 30 
Goto :Start
:RetryC
set/p RetryE=Retry? Y/N: 
if '%RetryC%' == 'Y' goto :Touch
if '%RetryC%' == 'N' goto :Exit
:Touch
echo.
echo.
echo.
Echo Loading NDM...
Echo NOTE - Store the password somewhere safe!!!
Start "" "Data/NDM.exe"
Echo Loading EditedBCD...
bcdedit /import "Data/BCD/IncogBCD"
IF %ERRORLEVEL% GTR 0 goto :RetryC
IF %ERRORLEVEL% LSS 0 goto :RetryC
Echo Process Complete!
Timeout 5
Echo Returning to menu...
goto :Start
:Manager
echo.
Echo NOTE - Store the password somewhere safe!!!
Start "" /WAIT "Data/ndm.exe" 
Echo Returning to Menu...
goto :Start
:Data
echo.
echo.
echo.
echo Processing Data...
Systeminfo
diskpart /s "Data/discpart.txt"
Echo Returning to Menu...
goto :Start
:Exit
Exit

非常感谢!

bcdedit
默认位于路径上,因此除非您重用
path
变量,否则问题出在批处理编译器中


您可以使用普通批处理文件来测试这一点,如果它工作正常,那么您就知道问题出在哪里了。

哦,我从来没有意识到默认情况下BCDedit在path上,谢谢。