简体   繁体   中英

Batch file to to open another batch file and then close itself

Here's what I have

@echo off
start "%~dp0Suffering.bat" Suffering.bat
@echo off

I've also tried

@echo off
start "%~dp0Suffering.bat" Suffering.bat
exit /b
@echo off

and

@echo off
start "%~dp0Suffering.bat" Suffering.bat
quit
@echo off

and

@echo off
"%~dp0Suffering.bat"
@echo off

The problem is, when opened, this batch file opens "suffering.bat" as it should, but it leaves an annoying cmd window open requesting admin privileges. I just want this batch to open the "suffering.bat" and nothing else...no other open windows. Kinda like a shortcut to "suffering.bat", because I have a bat to exe converter that only works with some batch files (not suffering.bat) and I need this in exe form. Any ideas?

exit /b tells windows to exit from the Batch and keep the cmd window open. Use exit only (without the /b ) to close the window too.

This question is really about the specific bat to exe converter. You're probably better off without it!

Here's how you'd do it in C:

#include <stdlib.h>

int main(int argc, char ** argv)
{
    system("suffering.bat");
    return 0;
}

That's going to be much simpler than trying to get a bat to exe converter to work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM