命令失败时,Windows 7退出批处理文件

时间:2015-05-12 13:40:04

标签: batch-file windows-7

我在Windows 7上编写批处理文件,一个接一个地执行一些命令:

copy source1 dest1
call someFile1.bat
copy source2 dest2
call someFile2.bat
copy source3 dest3

如果任何命令返回错误代码1,是否有办法返回错误代码1?

谢谢!

1 个答案:

答案 0 :(得分:1)

Yes, there is a way. The code must check the return code.

MasterObject = String, List<.ObjectA>

 Observable<ReturnObject> getReturnObject() { 

        Observable<MasterObject> masterObjectObservable = getMasterObjectObservable();


        Observable<String> myStringbservable = masterObjectObservable.map(new Func1<MasterObject, String>() {
            @Override
            public String call(MasterObject masterObject) {
                return masterObject.getString();
            }
        });

        return  masterObjectObservable.flatMap(new Func1<MasterObject, Observable<ObjectA>>() {
            @Override
            public Observable<MasterObject> call(MasterObject masterObject) {
                return Observable.from(masterObject.getList());
            }
        }).filter(new Func1<ObjectA, Boolean>() {
            @Override
            public Boolean call(ObjectA objectA) {
                return objectA.isTrue();
            }
        }).toList().concatWith(getSecondList(masterObjectObservable)).zipWith(publicKeyObservable, new Func2<List<ObjectA>, String, ReturnObject>() {
            @Override
            public ReturnObject call(List<ObjectA> listObjectA, String string) {
                return new ReturnObject(string, listObject);
            }
        });
}


private Observable<List<ObjectA>> getSecondList(Observable<MasterObject> masterObject) {
   return masterObject.flatMap(new Func1<MasterObject, Observable<ObjectA>>() {
        @Override
        public Observable<ObjectA> call(MasterObject masterObject) {
            return Observable.from(masterObject.getList());
        }
    }).filter(new Func1<ObjectA, Boolean>() {
        @Override
        public Boolean call(ObjectA objectA) {
            return objectA.isCondition();
        }
    }).toSortedList(new Func2<ObjectA, ObjectA, Integer>() {
        @Override
        public Integer call(ObjectA a, ObjectA b) {
            return a.getCondition()
                    .compareTo(b.getCondition());
        }
    });

}

If you want to check to see that the COPY commands work, that will be another if statement.