use .bat file to run python

target 1: run python in local machine

  1. simple
@echo off
python test.py

echo.
echo ** Please click the "X" button in the upper-right corner to close this window **
:loop
timeout /t 1 /nobreak >nul
tasklist | find "cmd.exe" >nul
if not errorlevel 1 goto loop
  1. activate conda activate
    在这里插入图片描述

the tartget exe file is %windir%\System32\cmd.exe "/K" C:\Users\zhaib\MiniConda3\Scripts\activate.bat C:\Users\zhaib\MiniConda3,

extract C:\Users\zhaib\MiniConda3\Scripts\activate.bat C:\Users\zhaib\MiniConda3 set into the following code.

@echo off
call C:\Users\zhaib\MiniConda3\Scripts\activate.bat C:\Users\zhaib\MiniConda3
call activate env_pytorch
:: do not use call conda activate env_pytorch or call source  activate env_pytorch
python test.py 


echo.
echo ** Please click the "X" button in the upper-right corner to close this window **
:loop
timeout /t 1 /nobreak >nul
tasklist | find "cmd.exe" >nul
if not errorlevel 1 goto loop

target 2: login remote linux system to execute python code

don’t know how to implement.

others

  1. close the windows only user click the top-right x
echo.
echo ** Please click the "X" button in the upper-right corner to close this window **
:loop
timeout /t 1 /nobreak >nul
tasklist | find "cmd.exe" >nul
if not errorlevel 1 goto loop
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值