exec in a bat file


junieman

Member
Local time
3:25 AM
Posts
30
OS
windows 11 pro
Is it possible to put an exec in a bat file directly?
I have several programs that I have on a flash drive that I would like to run out of a bat file and run it on any pc without loading them on each pc.
 

My Computer

System One

  • OS
    windows 11 pro
    Computer type
    PC/Desktop
    Manufacturer/Model
    dell
    CPU
    intel core i7-11700f
    Memory
    12 gb
    Monitor(s) Displays
    3
    Hard Drives
    256
    Keyboard
    wireless
    Mouse
    wireless
    Internet Speed
    50 mb
Yes, just provide the file path to the .exe file and it will run.

Batch:

Code:
notepad.exe
"C:\Program Files (x86)\Windows Kits\10\Debuggers\x64\windbg.exe"

Edit:

Code:
start "" "C:\Program Files (x86)\Windows Kits\10\Debuggers\x64\windbg.exe"

That will prevent the console window from opening.
 

My Computer

System One

  • OS
    Windows 11, Windows 10, Linux Mint XFCE, Linux Fedora Cinnamon
This does that: GitHub - illsk1lls/SFXcreator: Custom version of AveYo's BAT85/BAT91 encoding script

But it also uses powershell.

The first time you run the script it will add itself to your right-click “Send To” context menu, then after that just right click anything and “Send To” SFXCreator.cmd. It will create a SFX encoded CMD file containing whatever you selected with the option to run an executable after decompression.

You can split the decryption key for security if needed. In that case the file will only extract if you use the seperated key. If the .key file of the same name as the CMD file is present in the same directory it will auto-populate the input prompt. If you chose not to split the decryption key, it will be included in the CMD file and will extract normally without user input.
 
Last edited:

My Computer

System One

  • OS
    PE
I am trying to run the programs from a flash drive to make it portable with any pc.

I tried to download the SFXCreator.cmd but it shows that it probably contains a virus and should not be downloaded.
 

My Computer

System One

  • OS
    windows 11 pro
    Computer type
    PC/Desktop
    Manufacturer/Model
    dell
    CPU
    intel core i7-11700f
    Memory
    12 gb
    Monitor(s) Displays
    3
    Hard Drives
    256
    Keyboard
    wireless
    Mouse
    wireless
    Internet Speed
    50 mb
Just use the start command as shown in the above example, it will start any applications in that file path. The drive letter may change between systems so you can either edit it after plugging in the device or get the working directory of the script using: Get current batchfile directory
 

My Computer

System One

  • OS
    Windows 11, Windows 10, Linux Mint XFCE, Linux Fedora Cinnamon
I don't see the problem, or even the question.
When I'm setting up a new Windows ?? install, I use a series of batch files and scripts, to make changes to Windows. I call it tweaking and tuning.
Most of those batch files will run an EXE file to install some program on Windows. So far, I've never had a problem with it.

Before asking "Can I?" just try it. That's what I've been doing for decades.

TM :cool:
Merry Christmas
 

My Computer

System One

  • OS
    Win-11/Pro/64, Optimum 11 V3, 23H2 22631.3085
    Computer type
    PC/Desktop
    Manufacturer/Model
    Home Made w/Gigabyte mobo/DX-10
    CPU
    AMD FX 6350 Six Core
    Motherboard
    Gigabyte, DX-10, GA-78LMT-USB3
    Memory
    Crucial, 16 GB
    Graphics Card(s)
    Onboard, ATI Radeon HD 3000; NVIDEA GeForce 210, 1GB DDR3 Ram.
    Sound Card
    Onboard
    Monitor(s) Displays
    24" Acer
    Screen Resolution
    1280x800
    Hard Drives
    Crucial SSD 500GB, SanDisk 126GB SSD, Toshiba 1TB HD
    PSU
    EVGA 500 W.
    Case
    Pac Man, Mid Tower
    Cooling
    AMD/OEM
    Keyboard
    101 key, Backlit/ Mechanical Switches/
    Mouse
    Logitech USB Wireless M310
    Internet Speed
    Hughes Net speed varies with the weather
    Browser
    Firefox 64x
    Antivirus
    Windows Defender, Super Anti Spyware
    Other Info
    Given to me as DEAD, and irreparable.
    Rebuilt with Gigabyte mobo, AMD cpu, 16GB ram and 500GB Crucial SSD.
I have several programs that I have on a flash drive that I would like to run out of a bat file and run it on any pc without loading them on each pc

I do similar with my custom winpe. It finds the usb stick and links the program files on the usb stick to the pe desktop\start menu.

One way to do it is put a tag file on the root of the usb stick so it can be found. Anything with a unique name such as a .txt file called e.g. thisismystick.txt

I use pecmd to find the tag file and get the letter it is on, but it can be done with windows commands.

for example:

Code:
@echo off
for %%i in (A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) do (
    if exist "%%i:\thisismystick.txt" set usblett=%%i
     )
    echo %usblett%
     pause

rem then you know the path to usb\diskgenius\diskgenius.exe is %usblett%:\diskgenius\diskgenius.exe
 
Last edited:

My Computers

System One System Two

  • OS
    Win7
    Computer type
    PC/Desktop
    CPU
    i5-8400
    Motherboard
    gigabyte b365m ds3h
    Memory
    2x8gb 3200mhz
    Monitor(s) Displays
    benq gw2480
    PSU
    bequiet pure power 11 400CM
    Cooling
    cryorig m9i
  • Operating System
    win7
    Computer type
    PC/Desktop
    CPU
    pentium g5400
    Motherboard
    gigabyte b365m ds3h
    Memory
    1x8gb 2400
    PSU
    xfx pro 450
For my custom pe after finding the letter from the tag file, it loads another file on the root of the usb which does various things including linking the programs to the winpe desktop\start menu

something like:

LOAD usblett:\usbprogs.ini

usbprogs.ini contains this sort of stuff

in pecmd code %curdir% is similar to batchfile %~dp0 ( without the trailing backslash )

Code:
Createlnk
////////////////////////////////////////////////////////////
_SUB Createlnk
      //sets keyboard
     exec !wpeutil SetKeyboardLayout 0809:00000809

     ENVI PECMN=%CurDir%\USBprograms
     LINK %StartMenu%\AV\USB-Eset,%PECMN%\ESET\ESETonlinescanner.exe
     LINK %Desktop%\USB-Backupper,%PECMN%\AomeiBackupperx64\Backupper.exe
     LINK %Desktop%\USB-PartAssist,%PECMN%\AomeiPartAssistx64\PartAssist.exe
     LINK %Desktop%\USB-Palemoon,%PECMN%\Browserx64\Palemoon-portable.exe
     LINK %Desktop%\USB-Dism++,%PECMN%\Dism++\Dism++x64.exe
     LINK %StartMenu%\DiskTools\USB-DiskGenius,%PECMN%\DiskGeniusx64\DiskGenius.exe
     LINK %StartMenu%\DataRecovery\USB-Recuva,%PECMN%\Recuva\Recuva64.exe
     LINK %StartMenu%\DataRecovery\USB-Shadowcopyview,%PECMN%\shadowcopyview-x64\ShadowCopyViewx64.exe
     LINK %StartMenu%\Install\USB-WinNTSetup,%PECMN%\WinNTSetup\WinNTSetup_x64.exe
     LINK %StartMenu%\Registry\USB-Regscanner64,%PECMN%\USB-Regscanner\Regscanner64.exe
  
    FORX %PECMN%\regfiles\*.reg,&&rf,0,EXEC regedit /s %&rf%
    
     IFEX %WINDIR%\System32\Drivers\oodisr.sys,
       {  CALL $%CurDir%\USBprograms\OO Software\DiskImage\oodiagpsx64.dll
          EXEC %CurDir%\USBprograms\OO Software\DiskImage\oodiag.exe /service
          LINK %Desktop%\OOdiskImage,%PECMN%\OO Software\DiskImage\oodipro.exe
          }
  
     EXEC !"%PECMN%\AomeiPartAssist\install.bat"
     EXEC !wpeutil.exe EnableFirewall

     ENVI PECMN=
  
_END
 

My Computers

System One System Two

  • OS
    Win7
    Computer type
    PC/Desktop
    CPU
    i5-8400
    Motherboard
    gigabyte b365m ds3h
    Memory
    2x8gb 3200mhz
    Monitor(s) Displays
    benq gw2480
    PSU
    bequiet pure power 11 400CM
    Cooling
    cryorig m9i
  • Operating System
    win7
    Computer type
    PC/Desktop
    CPU
    pentium g5400
    Motherboard
    gigabyte b365m ds3h
    Memory
    1x8gb 2400
    PSU
    xfx pro 450
Last edited:

My Computers

System One System Two

  • OS
    Win7
    Computer type
    PC/Desktop
    CPU
    i5-8400
    Motherboard
    gigabyte b365m ds3h
    Memory
    2x8gb 3200mhz
    Monitor(s) Displays
    benq gw2480
    PSU
    bequiet pure power 11 400CM
    Cooling
    cryorig m9i
  • Operating System
    win7
    Computer type
    PC/Desktop
    CPU
    pentium g5400
    Motherboard
    gigabyte b365m ds3h
    Memory
    1x8gb 2400
    PSU
    xfx pro 450
The last free version of faststone capture works well in win10/11 custom pe even though it is more than 10 years old.

I had snipping tool in there but I prefer faststone. The old free version of faststone is 32 bit so the pe needs 32 bit support. Unless somebody can find 64 bit version of it.
 
Last edited:

My Computers

System One System Two

  • OS
    Win7
    Computer type
    PC/Desktop
    CPU
    i5-8400
    Motherboard
    gigabyte b365m ds3h
    Memory
    2x8gb 3200mhz
    Monitor(s) Displays
    benq gw2480
    PSU
    bequiet pure power 11 400CM
    Cooling
    cryorig m9i
  • Operating System
    win7
    Computer type
    PC/Desktop
    CPU
    pentium g5400
    Motherboard
    gigabyte b365m ds3h
    Memory
    1x8gb 2400
    PSU
    xfx pro 450
I am trying to run the programs from a flash drive to make it portable with any pc.

I tried to download the SFXCreator.cmd but it shows that it probably contains a virus and should not be downloaded.
not a virus, its av being overprotective, you can see the code (of the tool)

But there are better methods to make portable programs, some listed above.

Also 7zSFX Constructor: 7zSFX Constructor
 
Last edited:

My Computer

System One

  • OS
    PE
Is it possible to put an exec in a bat file directly?
I have several programs that I have on a flash drive that I would like to run out of a bat file and run it on any pc without loading them on each pc.
It sounds like you may have asked the wrong question. If I understand correctly, you want to be able to run certain programs from a flash drive, on any PC, without having to install them first. That's not a matter of doing something with a batch file. It's a matter of understanding the difference between an installed program and a portable program and focusing on getting portable versions or making portable versions from installed versions.

The general strategy is to choose programs that are already available in a portable version whenever possible. When that's not possible, you can often find that someone else has already created a portable version. For example, by default, Recuva is not a portable program (which is really quite dumb). But, if you search for a portable version of recuva, you'll find it at rcvPortable (file recovery utility) | PortableApps.com.

And if you want to batch up multiple changes that can be applied to every new machine / new user, then you should really focus on command line utilities and PowerShell scripts. A batch file certainly can be used to chain together a bunch of commands or scripts and is a good way to get everything launched (e.g. bypass PowerShell default security settings).
 

My Computer

System One

  • OS
    Windows 10/11
    Computer type
    Laptop
    Manufacturer/Model
    Acer
Back
Top Bottom