重定向CMD命令到一个EXE文件 [英] Redirecting CMD Commands To An EXE File

查看:340
本文介绍了重定向CMD命令到一个EXE文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本上我已经创建了一个选择批次,每隔一段时间,我可以,因为我改变它经常存档我的引导数据的内容和它的作品绝对完美的,但是我面对每一次我从编译.BAT批次问题to.EXE高级BAT为EXE转换器命令'BCDEDIT'永远不会奏效并说:不被识别为一个内部或外部命令,可操作的程序或批处理文件。
现在我做的第一件事就是确保如果我有我的指示硬盘驱动器的环境变量,它似乎罚款:

Basically I have created an choice batch that every so often I can archive the contents of my boot data since I change it quite often and it works absolutely perfect, however I face the problem that every time I compile the batch from .BAT to.EXE with Advanced BAT to EXE converter the command 'bcdedit' never works and says "Not recognised as an internal or external command, operable program or batch file." Now the first thing I did was to make sure if I had the environment variables directed on my hard drive and it seemed fine:

路径: %SystemRoot%\\system32;%SystemRoot%;%SystemRoot%\\System32\\Wbem;%SYSTEMROOT%\\System32\\WindowsPowerShell\\v1.0\\;C:\\Program文件(x86)\\ QuickTime的\\ QTSystem \\; C:\\ Program Files文件(x86)的\\英特尔\\ OpenCL的SDK \\ 2.0 \\ BIN \\ 86; C:\\ Program Files文件(x86)的\\英特尔\\ OpenCL的SDK \\ 2.0 \\ BIN \\ 64; C:\\用户\\支持\\ DOCUME〜1 \\ MYFILE〜1 \\程序\\ SYSTEM〜1 \\ DISKEE〜1 \\

它完美工作所需的所有变量再加上一些外部因素是确定,然后我想,也许我应该尽量做到直接在我的文件夹中,做一些研究,我在另一个论坛中发现:
<一href=\"http://superuser.com/questions/65816/setting-or-modifying-a-system-wide-environment-variable-in-cmd-exe\">Setting或修改全系统环境变量CMD.EXE
我做了一个单独的.BAT,我把它称为,它似乎它没有创建单独的变量:

It has all the variables needed to work perfectly plus a few external ones which is ok then I thought that maybe I should try to make it direct on my folder, by doing some research I found on another forum: Setting or Modifying a System Wide Environment Variable In CMD.EXE I made a separate .BAT and I called it and it seems it did create the separate variable:

C:\\Users\\???\\Documents\\;C:\\Windows\\system32;C:\\Windows;C:\\Windows\\System32\\Wbem;C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\Program文件(x86)\\ QuickTime的\\ QTSystem \\; C:\\ Program Files文件(x86)的\\英特尔\\ OpenCL的SDK \\ 2.0 \\ BIN \\ 86; C:\\ Program Files文件(x86)的\\英特尔\\ OpenCL的SDK \\ 2.0 \\ BIN \\ 64; C:\\用户\\支持\\ DOCUME〜1 \\ MYFILE〜1 \\程序\\ SYSTEM〜1 \\ DISKEE〜1/˚F

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\x86;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x64;C:\Users\Support\DOCUME~1\MYFILE~1\Programs\SYSTEM~1\DISKEE~1" /f

但它仍然没有工作!

我在读另一种形式:

SYSWOW64重定向

该人士解决方案是使用创建进程()创建一个程序,自动重定向他用sysnative(System32)中的文件夹,但我在C#中的总初学者,CMD是我最强的区域,当涉及到编码。

The person solution was to use Create Process () to create a program that automatically redirects him to the folder using sysnative (System32) but I'm a total beginner at C#, CMD is my strongest area when it comes to coding.

请请我求求你尽快帮我,如果你有一个答案,请以最简单的方式可能的,为什么状态。这里是我的脚本,以防万一:

Please please I beg of you to help me as soon as possible and if you do have an answer please state in the easiest way possible and why. Here's my script just in case:

    :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 is on the path by default so unless you are reusing the PATH variable then the problem is in the batch compiler.

您可以通过使用简单的批处理文件测试这一点 - 如果它工作,那么你知道问题出在哪里。

You can test this by using the plain batch file - and if it works then you know where the problem is.

这篇关于重定向CMD命令到一个EXE文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆