convert batch file to executable
Results 1 to 4 of 4

Thread: convert batch file to executable

  1. #1
    Join Date
    Mar 2002
    Posts
    2

    convert batch file to executable

    Hello to all the dos experts. I hope you could help me with this simple batch commands that uses environment variable to output it to a text file.
    Code:
    @echo off
          echo setl "SU_COMMANDLINE=%COMSPEC% /c start c:\winnt\system32\command.com /Q /I" >%temp%\trash.kix
          echo setl "SU_PASSWORD=password"                         >>%temp%\trash.kix
          echo go C:                                               >>%temp%\trash.kix
          echo $cmd=ExpandEnvironmentVars(CHR(37)+comspec+CHR(37)) >>%temp%\trash.kix
          echo shell $cmd+' /c dir c:\windows\*.ini /w'            >>%temp%\trash.kix
          echo ; shell $cmd+' /c su userid -l -e -cb -w'           >>%temp%\trash.kix
          echo $tmp=ExpandEnvironmentVars(CHR(37)+temp+CHR(37))    >>%temp%\trash.kix
          echo ; del $tmp+'\trash.kix'                             >>%temp%\trash.kix
          kix32 %temp%\trash.kix
    @echo off
    This batch works in batch mode. When I convert it to a com file using Bat2exec program, it doesn't work. Can anyone help?

  2. #2
    Join Date
    Nov 2001
    Location
    Fishbel
    Posts
    2,412
    I'm a huge fan of bat2exe, I use it quite often, but I'm at a loss as to why it doesn't work. You might experiment to see if it properly displays the value of the variable %temp% when in the executable.

    Create a new batch that is simply
    • echo %temp%
    and see if it displays the same value both as a .BAT and after being converted to a .COM by bat2exe. (It appears that this is under Windows NT so that command should work fine, it's working on my XP machine.)

    You may have to hard-code the actual path into the batch file, but you haven't really told us what works or what doesn't work, and I'm too lazy to try it myself.

    ------------------
    Am386DX-40 + Cx387DX-40
    32MB, 128KB cache
    (2) 540MB HD's
    8x CD
    2MB Video
    SB16 PnP
    DR-DOS 7.04
    Win3.11 w/ Win32s
    --
    Just because it's unusual doesn't make it a virus!
    Ping is NOT an acronym!

    [This message has been edited by AlaricD (edited 03-12-2002).]
    Welcome to the Eclipse(C). The Evolution of an Idea
    Options: DCM3 LCR VMS CVM Sil CPI VMI ANI 648 CA1 SACD500 Att CID RLS TIME DLG

    Version: ECLIPSE 2.0.0 09/09/98 System is BUSY Thu 07-21-05 1:31 pm
    Access Level = 10 Port = 10

  3. #3
    Join Date
    Mar 2002
    Posts
    2
    AlaricD, thanks for your response. You're right, I have tested it using absolute path instead of using system variables and it is working now on exe. Though, I'm wondering why it is not working on system variable when the batch file is converted into exe using bat2exe? Any thoughts?

    Thanks alot.

  4. #4
    Join Date
    Nov 2001
    Location
    Fishbel
    Posts
    2,412
    Originally posted by jvd626:
    AlaricD, thanks for your response. You're right, I have tested it using absolute path instead of using system variables and it is working now on exe. Though, I'm wondering why it is not working on system variable when the batch file is converted into exe using bat2exe? Any thoughts?

    Thanks alot.
    I'm not really sure why, but it may be that bat2exe doesn't tokenize those variables properly. I would have thought that at least it would fill in the variables as were current from the environment at compilation, making the program not work on other machines if their paths were set up differently, but apparently it works still differently. Or, the executable just ignores environment settings when it runs.

    bat2exe does work pretty well with those batch files that use a command line parameter, so it's not like it can't handle variables at all. It just seems like it's one of those things you have to live with...

    Happy programming!



    ------------------
    Am386DX-40 + Cx387DX-40
    32MB, 128KB cache
    (2) 540MB HD's
    8x CD
    2MB Video
    SB16 PnP
    DR-DOS 7.04
    Win3.11 w/ Win32s
    --
    Just because it's unusual doesn't make it a virus!
    Ping is NOT an acronym!
    Welcome to the Eclipse(C). The Evolution of an Idea
    Options: DCM3 LCR VMS CVM Sil CPI VMI ANI 648 CA1 SACD500 Att CID RLS TIME DLG

    Version: ECLIPSE 2.0.0 09/09/98 System is BUSY Thu 07-21-05 1:31 pm
    Access Level = 10 Port = 10

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •