使用批处理文件重新启动终端应用程

时间:2015-12-29 02:08:45

标签: windows batch-file cmd

我需要一个.bat文件,它将关闭并重新打开start.cmd(C:\ Users \ Jake \ Desktop \ PocketMine-MP \ start.cmd)< - 这就是文件位置。我需要它每75分钟关闭并重新打开一次。终端必须关闭它不能保持打开并启动另一个我到目前为止所有:

@echo off
:loop
start "start.cmd" "C:\Users\Jake\Desktop\PocketMine-MP\start.cmd 
timeout /t 20
taskkill /f /im "start.cmd" >nul
goto loop

它每隔20秒就像我想要的那样启动终端,但它没有关闭旧的终端。 如果有人能提供帮助,那将有助于我和我的小网络。

3 个答案:

答案 0 :(得分:2)

public class ListViewAdapter extends BaseAdapter { // Declare Variables MainActivity main; private PublisherInterstitialAd mPublisherInterstitialAd; Context context; LayoutInflater inflater; ArrayList<HashMap<String, String>> data; ImageLoader imageLoader; HashMap<String, String> resultp = new HashMap<String, String>(); public ListViewAdapter(Context context, ArrayList<HashMap<String, String>> arraylist) { this.context = context; data = arraylist; imageLoader = new ImageLoader(context); } @Override public int getCount() { return data.size(); } @Override public Object getItem(int position) { return null; } @Override public long getItemId(int position) { return 0; } public View getView(final int position, View convertView, ViewGroup parent) { // Declare Variables TextView rank; TextView country; TextView population; ImageView flag; inflater = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); View itemView = inflater.inflate(R.layout.listview_item, parent, false); // Get the position resultp = data.get(position); // Locate the TextViews in listview_item.xml //rank = (TextView) itemView.findViewById(R.id.rank); country = (TextView) itemView.findViewById(R.id.country); // population = (TextView) itemView.findViewById(R.id.population); // Locate the ImageView in listview_item.xml flag = (ImageView) itemView.findViewById(R.id.flag); // Capture position and set results to the TextViews // rank.setText(resultp.get(MainActivity.VIDEO_ID)); country.setText(resultp.get(MainActivity.TITLE)); // population.setText(resultp.get(MainActivity.DESCRIPTION)); // Capture position and set results to the ImageView // Passes flag images URL into ImageLoader.class imageLoader.DisplayImage(resultp.get(MainActivity.imgURL), flag); // Capture ListView item click mPublisherInterstitialAd = new PublisherInterstitialAd(context); mPublisherInterstitialAd.setAdUnitId("ca-app-pub-4265785833148880/6768099054"); mPublisherInterstitialAd.setAdListener(new AdListener() { @Override public void onAdClosed() { requestNewInterstitial(); } }); requestNewInterstitial(); itemView.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // Get the position resultp = data.get(position); Intent intent = new Intent(context, PlayerViewDemoActivity.class); intent.putExtra("videoId", resultp.get(MainActivity.VIDEO_ID)); context.startActivity(intent); mPublisherInterstitialAd.isLoaded(); mPublisherInterstitialAd.show(); requestNewInterstitial(); } }); return itemView; } 重命名为start.cmd,然后尝试以下操作。

bat_start.cmd

答案 1 :(得分:0)

如果您使用相同的文件来控制循环并再次启动文件,那么它会递归递归。以下为我的示例工作,

{ searchStatus: status }

test2文件

@echo off
:loop
start "test2" "C:\test2.bat"
timeout /t 60
taskkill /f /fi "windowtitle eq test2*" /im "cmd.exe" >nul
goto loop

答案 2 :(得分:0)

您可以使用TimeCommander插件。设置为每75分钟运行一次重新启动命令。