用了一个代码后bat都变全屏海报代码了

[代码全屏查看]-Win7程序自删除(批处理方式)的一种实现
[代码] [C/C++]代码
/***********************************************************************************
* 程序描述: 本程序为Windows7环境下,程序自删除的一种实现方式
* 运行环境: Win7
* 开发环境: VS2012
* 调用接口函数库类型: Windows API,标准C库函数
* 程序原理: Windows加载程序后,进程无法删除进程映像,利用批处理延时加载,进程退出后,
利用批处理删除映像文件
***********************************************************************************/
#include "stdafx.h"
#include &stdio.h&
#include &string.h&
#include &windows.h&
void DelItself()
HANDLE hFile = CreateFileA("1.bat",
GENERIC_WRITE,0,
NULL,CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL,
if(hFile == INVALID_HANDLE_VALUE)
char *szBat = "del DelItself.exe\r\n del 1.bat";
DWORD dwNum = 0;
//向1.bat批处理文件中写入删除进程映像的命令
WriteFile(hFile,szBat,lstrlenA(szBat)+1,&dwNum,NULL);
CloseHandle(hFile);
ShellExecuteA(NULL,"open","1.bat","","",SW_HIDE);
int _tmain(int argc, _TCHAR* argv[])
char szInputStr[MAXBYTE];
//输入delete,触发程序自删除
scanf("%s",szInputStr);
if(0 == strncmp(szInputStr, "delete", MAXBYTE))
printf("程序正在自删除...........\n");
DelItself();1468人阅读
想写一个批处理文件去调用多个批处理文件,按照以前写的调用多个程序的方法
startAll.bat
--------------------内容----------
然后发现,a.bat执行完了后,这个批处理文件就直接停止了。
查询资料后发现应该使用call
于是更改为
startAll.bat
--------------------内容----------
Call&a.bat
Call b.bat
Call c.bat
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:240480次
积分:3560
积分:3560
排名:第3797名
原创:101篇
转载:75篇
评论:110条
(1)(1)(1)(1)(2)(1)(2)(7)(5)(6)(3)(2)(9)(6)(2)(4)(4)(9)(2)(4)(4)(18)(7)(5)(7)(3)(13)(10)(8)(7)(3)(2)(6)(8)(3)批处理问题 我想用一个bat文件创建一个新的bat文件,并写入代码_百度知道
批处理问题 我想用一个bat文件创建一个新的bat文件,并写入代码
能用这样的例子吗?echo XXX&123.bat XXX代表的是批处理代码
提问者采纳
&gt.bat123。 举个例子,就是有些符号啊;123:echo echo 这是个例子&gt.batecho pause&123,以及命令用法要注意一点可以
其他类似问题
bat文件的相关知识
其他3条回答
可以,这种用法很常见。
完全可以这个方法很实用的需要注意的是,注意特殊符号用转义比如echo echo echo 小心 ^&^&2.bat&&1.bat呵呵 请注意体会
楼上都答得对,我再补充详细一点
1 你所说的代码XXX中如含&&&| 需在每个这类符号前加转义符 ^ 不然把它当本批处理的命令试图运行
2 如果你写这句代码处在某括号之中,那么括号也很特殊,可能也要加 ^ 来转义其他的我没仔细想,也许还有,例如符号 ! 总之可能对本批处理会起到改变命令作用的都要转义
3 如果代码中有转义符本身,则它也要转义,等于是双写
4 符号 % 也是要转义,但不能用 ^
而是双写自己,当然如果是想把本次批处理中的某变量值传递到新批处理中(即在新批处理中此处已是常量)另当别论,从某个意义上说,这种情况用批处理建批处理有一定实际意义——只有运行本批处理,才能得到运行另一批处理需要的数据
5 如果写入另一批处理的代码较多,且排除了上一条所说的传递变量值的情况,可用另一方法不用转义就照代码需要格式写,方法是在本批处理最后加一句more +8 %0&123.bat&exit
(这里的数字8表示到本行共有多少行,据实改)表示把本批处理第8行之后的内容写入新批处理并退出(即不执行之后的代码)再把要写入的所有代码写在本批处理的最后
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁[代码全屏查看]-使用mybatis3与spirng3配置文件中的一个坑
[1].[代码] spring配置mybatis的文件
&?xml version="1.0" encoding="UTF-8"?&
&beans xmlns="http://www.springframework.org/schema/beans"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd "&
&bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"&
&property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" /&
&property name="ignoreResourceNotFound" value="true" /&
&property name="locations"&
&!-- 系统配置 --&
&value&classpath*:db.config.properties&/value&
&/property&
&!-- 使用annotation自动注册bean,并保证@Required,@Autowired的属性被注入 --&
&context:annotation-config /&
&context:component-scan base-package="com.test" /&
&!-- 数据源配置,使用alibaba的druid数据库连接池 --&
&bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource"
init-method="init" destroy-method="close"&
&property name="url" value="${jdbc.url}" /&
&property name="username" value="${jdbc.user}" /&
&property name="password" value="${jdbc.password}" /&
&!-- 配置初始化大小、最小、最大 --&
&property name="initialSize" value="1" /&
&property name="minIdle" value="1" /&
&property name="maxActive" value="20" /&
&!-- 配置获取连接等待超时的时间 --&
&property name="maxWait" value="60000" /&
&!-- 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 --&
&property name="timeBetweenEvictionRunsMillis" value="60000" /&
&!-- 配置一个连接在池中最小生存的时间,单位是毫秒 --&
&property name="minEvictableIdleTimeMillis" value="300000" /&
&property name="validationQuery" value="SELECT 'x'" /&
&property name="testWhileIdle" value="true" /&
&property name="testOnBorrow" value="false" /&
&property name="testOnReturn" value="false" /&
&!-- 打开PSCache,并且指定每个连接上PSCache的大小 --&
&property name="poolPreparedStatements" value="true" /&
&property name="maxPoolPreparedStatementPerConnectionSize"
value="20" /&
&!-- 配置监控统计拦截的filters --&
&property name="filters" value="stat,slf4j" /&
&!-- 配置事务管理器 --&
&bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"&
&property name="dataSource" ref="dataSource"&&/property&
&!-- myBatis 配置 --&
&bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"&
&property name="configLocation" value="classpath:mybatis.xml" /&
&property name="dataSource" ref="dataSource" /&
&!-- 配置sqlSessionTemplate --&
&bean id="sqlSessionTemplate" class="org.mybatis.spring.SqlSessionTemplate"&
&constructor-arg index="0" ref="sqlSessionFactory" /&
&!-- mybatis 自动装载 mapper的xml文件 --&
&bean id="mybatisMapperScannerConfigure" class="org.mybatis.spring.mapper.MapperScannerConfigurer"&
&property name="basePackage" value="com.test.mapper" /&
[2].[代码] baseDao的简单配置
import org.mybatis.spring.support.SqlSessionDaoS
public abstract class BaseDao&T& extends SqlSessionDaoSupport {
protected &S& S getMapper(Class&S& clazz) {
return getSqlSession().getMapper(clazz);
[3].[代码] 出问题的地方
当时采用的是传统的继承 SqlSessionDaoSupport 的方式构建 baseDao,然后构建各个功能dao来继承这个baseDao,可以直接使用SqlSessionDaoSupport中继承来的 getSqlSession()方法来获取sqlSession,用来执行sql,原本都没有问题,但是这次我用maven添加依赖时候,选择的是最新版本的 mybatis-spring-1.2.0.jar, 啊哦,坑来了。
注意看1.2.0中的SqlSessionDaoSupport所对应的javadoc的注释:
* Convenient super class for MyBatis SqlSession data access objects.
* It gives you access to the template which can then be used to execute SQL methods.
* This class needs a SqlSessionTemplate or a SqlSessionFactory.
* If both are set the SqlSessionFactory will be ignored.
* {code Autowired} was removed from setSqlSessionTemplate and setSqlSessionFactory
* in version 1.2.0.
* @see #setSqlSessionFactory
* @see #setSqlSessionTemplate
* @see SqlSessionTemplate
* @version $Id$
注意到 {code Autowired} was removed from setSqlSessionTemplate and setSqlSessionFactory 这句话,坑爹啊,也就是说当你使用1.2.0的jar包时候,mybatis-spring的这个基类不会再直接将spring配置文件中配好的 sqlSessionFactory 或者 sqlSessionTemplate注入到这个基类中,而在使用时候,SqlSessionDaoSupport的方法
protected void checkDaoConfig() {
notNull(this.sqlSession, "Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required");
就会抛出对应的异常了
[4].[代码] 给出SqlSessionDaoSupport类 1.2.0 和 1.1.1版本的区别
The MyBatis Team
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
package org.mybatis.spring.
import static org.springframework.util.Assert.notN
import org.apache.ibatis.session.SqlS
import org.apache.ibatis.session.SqlSessionF
import org.mybatis.spring.SqlSessionT
import org.springframework.dao.support.DaoS
* Convenient super class for MyBatis SqlSession data access objects.
* It gives you access to the template which can then be used to execute SQL methods.
* This class needs a SqlSessionTemplate or a SqlSessionFactory.
* If both are set the SqlSessionFactory will be ignored.
* {code Autowired} was removed from setSqlSessionTemplate and setSqlSessionFactory
* in version 1.2.0.
* @see #setSqlSessionFactory
* @see #setSqlSessionTemplate
* @see SqlSessionTemplate
* @version $Id$
public abstract class SqlSessionDaoSupport extends DaoSupport {
private SqlSession sqlS
private boolean externalSqlS
public void setSqlSessionFactory(SqlSessionFactory sqlSessionFactory) {
if (!this.externalSqlSession) {
this.sqlSession = new SqlSessionTemplate(sqlSessionFactory);
public void setSqlSessionTemplate(SqlSessionTemplate sqlSessionTemplate) {
this.sqlSession = sqlSessionT
this.externalSqlSession =
* Users should use this method to get a SqlSession to call its statement methods
* This is SqlSession is managed by spring. Users should not commit/rollback/close it
* because it will be automatically done.
* @return Spring managed thread safe SqlSession
public SqlSession getSqlSession() {
return this.sqlS
* {@inheritDoc}
protected void checkDaoConfig() {
notNull(this.sqlSession, "Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required");
1.1.1 版本
Copyright 2010 The myBatis Team
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
package org.mybatis.spring.
import org.apache.ibatis.session.SqlS
import org.apache.ibatis.session.SqlSessionF
import org.mybatis.spring.SqlSessionT
import org.springframework.beans.factory.annotation.A
import org.springframework.dao.support.DaoS
import org.springframework.util.A
* Convenient super class for MyBatis SqlSession data access objects.
* It gives you access to the template which can then be used to execute SQL methods.
* This class needs a SqlSessionTemplate or a SqlSessionFactory.
* If both are set the SqlSessionFactory will be ignored.
* @see #setSqlSessionFactory
* @see #setSqlSessionTemplate
* @see SqlSessionTemplate
* @version $Id: SqlSessionDaoSupport.java -22 06:56:51Z simone.tripodi $
public abstract class SqlSessionDaoSupport extends DaoSupport {
private SqlSession sqlS
private boolean externalSqlS
@Autowired(required = false)
public final void setSqlSessionFactory(SqlSessionFactory sqlSessionFactory) {
if (!this.externalSqlSession) {
this.sqlSession = new SqlSessionTemplate(sqlSessionFactory);
@Autowired(required = false)
public final void setSqlSessionTemplate(SqlSessionTemplate sqlSessionTemplate) {
this.sqlSession = sqlSessionT
this.externalSqlSession =
* Users should use this method to get a SqlSession to call its statement methods
* This is SqlSession is managed by spring. Users should not commit/rollback/close it
* because it will be automatically done.
* @return Spring managed thread safe SqlSession
public final SqlSession getSqlSession() {
return this.sqlS
* {@inheritDoc}
protected void checkDaoConfig() {
Assert.notNull(this.sqlSession, "Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required");
[5].[代码] 传统配置的解决办法
配置文件跟我 贴出来的配置文件一样,不需要做改动,只需要在baseDao中注入sqlSessionFactory 或者 sqlSessionTemplate即可,代码如下:
BaseDao.java
import org.mybatis.spring.SqlSessionT
import org.mybatis.spring.support.SqlSessionDaoS
import org.springframework.beans.factory.annotation.A
public abstract class BaseDao&T& extends SqlSessionDaoSupport {
@Autowired
public void setSqlSessionTemplate(SqlSessionTemplate sqlSessionTemplate) {
super.setSqlSessionTemplate(sqlSessionTemplate);
protected &S& S getMapper(Class&S& clazz) {
return getSqlSession().getMapper(clazz);
[6].[代码] 关于这里的一些问题
对于1.2.0的这个地方的改动,想了一下,估计设计者是考虑到在web应用中可能因为读写分离或者应用场景的问题,会使用多一个数据源的设置,如果按照1.1.1的默认注入方式来的话,就比较难以实现,而1.2.0则允许用户自己通过
@Autowired
@Qualifier("db1")
@Autowired
@Qualifier("db2")
的方式选择不同的数据源,但是最坑爹的是,没有详细的提示,搞死人啊。。。。。
还有一个问题,目前我还没有找到解决方案,在BaseDao.java中,是在setSqlSessionTemplate这个方法上采用 @autowired的方式注入的,如果不采用这种方式,而是直接在配置文件中配置bean的方式如何能实现,还请大家想想办法,谢谢。kettle脚本调度 - CSDN博客
本周项目上用到了kettle并且需要做任务调度,听老师说用kettle自带的调度不大稳定于是便baidu了下,参照这篇文章完成了通过kitchen的调度,简单说就是通过windows的计划任务来调用.bat的批处理文件来开始kettle作业。
先普及一点知识
Kettle是一个开源的ETL(Extract-Transform-Load的缩写,即数据抽取、转换、装载的过程)项目,项目名很有意思,水壶。按项目负责人Matt的说法:把各种数据放到一个壶里,然后呢,以一种你希望的格式流出。Kettle包括三大块:
& &Spoon——转换/工作(transform/job)设计工具 (GUI方式)
& &Kitchen——工作(job)执行器 (命令行方式)
& &Span——转换(trasform)执行器 (命令行方式)
Kettle是一款国外开源的etl工具,纯java编写,绿色无需安装,数据抽取高
效稳定。Kettle中有两种脚本文件,transformation和job,transformation完成针对数据的基础转换,job则完成整个工作流的控制。
因为最近工作需要所以不得不研究下调用kitchen.bat后面接参数的问题。
经过一段时间的研究终于知道传参的方法了。
kitchen.bat& &后面可以是-也可以是/然后再加options
/rep& && &&&: Repository name
/user& && & : Repository username
/pass& && & : Repository password
/job& && &&&: The name of the job to launch
/dir& && &&&: The directory (dont forget the leading /)
/file& && & : The filename (Job XML) to launch
/level& && &: The logging level (Basic, Detailed, Debug, Rowlevel, Error, Nothing)
/logfile& & : The logging file to write to
/listdir& & : List the directories in the repository
/listjobs& &: List the jobs in the specified directory
/listrep& & : List the available repositories
/norep& && &: Do not log into the repository
/version& & : show the version, revision and build date
/param& && &: Set a named parameter &NAME&=&VALUE&. For example -param:FOO=bar
/listparam : List information concerning the defined parameters in the specified job.
/export& &&&: Exports all linked resources of the specified job. The argument is the name of a ZIP
而options 后面可以是=也可以是:也可以是空格
kitchen.bat /file d:\& &或者 -file=D:\ 或者/file:D:\等等都可以。。。
定时执行的代码参考如下【原创】,可以执行的实例
1、windows下的执行方式:
建立一个mysql.dat的文件,里面写入
cd D:/Kettle-3.0.2
kitchen.bat /norep -file=D:/kettledata/mysal2orcle.kjb && kitchen_%date:~0,10%.log
保存文件。
解释一下上面的语句
cd D:/Kettle-3.0.2 这句的含义是跳转到kettle的根目录,因为kitchen.bat 文件在根目录下
kitchen.bat /norep -file=D:/kettledata/mysal2orcle.kjb && kitchen_%date:~0,10%.log
上面的含义是,使用kitchen.bat 命令来执行job文件,job文件的存放路径是D:/kettledata/mysal2orcle.kjb,并且将执行的结果输出到 kitchen_%date:~0,10%.log文件中。
2、linux下的书写格式:
创建mysqldb.sh
cd /home/Kettle-3.0.2 这句的含义是跳转到kettle的根目录,因为kitchen.bat 文件在根目录下
./kitchen.sh -file=/home/etl/mysql.kjb && /home/etl/log/kettle.log
然后这个文件在crontab中去执行
注意:linux执行shell过程中,由于linux对权限要求很严格,所以kitchen.sh必须有可执行的权限。前面必须加上./,也就是./kitchen.sh才能执行,否则会提示找不到此命令。
kitchen.bat的使用方法:
Kitchen.bat /file:D:\job_name.kjb /level:Basic&&D:\etl.log
使用心得:
1.file和level都是前面有‘/’,后面有‘:’,任何一个都不能丢。
2.此语句要在一行上完成,中间不能有换行符之类的。
博主从昨天就开始调试的几个bat文件,始终不能在我指定的文件里面记日志,一直在dos界面记录,苦思不得其果,偶然的一个把bat文件全屏之后,发现原来语句被换行了,修改到同一行之后可以顺利的运行。
3.此语句后面不能接任何语句,就算你在bat文件里面添加了别的语句,也不会得到执行,查阅了好多资料,没有发现解决办法,逼不得已,我只能把job做成了一个一个单独的bat文件,这个有点儿杯具。
4.JDK或者JRE很重要。
博主因为服务器上没有配置java环境,吃了不少苦。
先是没装java环境,无法运行kettle;接着装好了java环境之后,job和转换可以正常运行,但是kitchen.bat语句不能正常运行,又查阅了一堆资料后发现,原来是环境变量的问题,设置了环境变量之后总算可以正常运行了。
有一篇介绍
Kitchen——作业执行器&& &
是一个作业执行引擎,用来执行作业。这是一个命令行执行工具,没啥可讲的,就把它的参数说明列一下。
& & -rep& && &: Repository name& &任务包所在存储名
& & -user& &&&: Repository username& &执行人
& & -pass& &&&: Repository password& &执行人密码
& & -job& && &: The name of the job to launch 任务包名称
& & -dir& && &: The directory (don''t forget the leading / or \)&
& & -file& &&&: The filename (Job XML) to launch&
& & -level& & : The logging level (Basic, Detailed, Debug, Rowlevel, Error, Nothing) 指定日志级别
& & -log& && &: The logging file to write to&&指定日志文件
& & -listdir&&: List the directories in the repository 列出指定存储中的目录结构。
& & -listjobs : List the jobs in the specified directory 列出指定目录下的所有任务
& & -listrep&&: List the defined repositories 列出所有的存储
& & -norep& & : Don''t log into the repository&&不写日志
& & 嗯,居然不支持调度。看了一下文档,建议使用操作系统提供的调度器来实现调度,比如:Windows可以使用它的任务计划工具。}

我要回帖

更多关于 全屏代码 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信