1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Help with Batch File

Discussion in 'HTML, Graphics & Programming' started by That Guy, 11 Apr 2010.

  1. That Guy

    Gangster

    Joined: 31 Jan 2010

    Posts: 282

    Location: UK

    I haven't really played with batch files since back in the day when I was running MS-DOS 5.0 :D

    I have created a batch file that will install an OEM Logo and Information on Windows Vista and Windows 7. This is fine but it only works if the the system drive is "C".

    Can someone add something in after the pause command so that they have to press corresponding key for their drive. For example if their system drive is "D" they would press the "D" button and it will carry on installing to that drive.

    I would also love to turn this script into a .EXE file and have an icon for it, so if anyone knows of any good .BAT to .EXE converters please let me know.

    Thanks In Advance :)

    Code:
    @echo off
    cls
    echo This installer will install your OEM
    echo Information to your Windows Vista or
    echo Windows 7 Computer.
    echo.
    echo This installer is NOT compatible with XP
    echo or any other Windows Version.
    echo.
    echo.
    echo.
    pause
    copy OEMLogo.bmp C:\windows\system32
    OEMLogo.reg
     
  2. marc2003

    Capodecina

    Joined: 6 Feb 2004

    Posts: 20,239

    Location: England

    Code:
    copy OEMLogo.bmp %windir%\system32
     
  3. That Guy

    Gangster

    Joined: 31 Jan 2010

    Posts: 282

    Location: UK

    Is it really that easy?? :D Now I feel stupid.

    Does anyone know how to compile the batch file as a .EXE file and add an icon to it?
     
  4. K.C. Leblanc

    Sgarrista

    Joined: 13 Sep 2003

    Posts: 8,163

    Location: Glocestershire

    I don't think you can compile batch files. One way round it would be to put the batch file and your image in a self extracting zip file. I think you can specify a file to be run after the zip has extracted.

    You could also look at Autoit which is an alternative to BAT which can be compiled into an EXE.

    Another option is to use either of these two to make an installer instead.

    http://nsis.sourceforge.net/Main_Page

    http://www.advancedinstaller.com/

    Nullsoft I've never used but it's quite popular. Advanced I use quite a bit, it's very good, but I think the free version put a message in the installer saying it was made using the free version (the installs I create are usually ran silently).

    EDIT: Ok you can compile a bat, http://www.abyssmedia.com/quickbfc/

    EDITEDIT: I know it's probably just a wrapper, and it will still be interpreted so it isn't technically compiled.

    EDITEDITEDIT: And the same goes for Autoit.
     
    Last edited: 11 Apr 2010
  5. That Guy

    Gangster

    Joined: 31 Jan 2010

    Posts: 282

    Location: UK

  6. Feek

    Commissario

    Joined: 16 Oct 2002

    Posts: 231,971

    Location: In the radio shack

    I used to use bat2com to wrap simple batch files into .com back in t'day. Not sure if that's still a valid option or not.
     
  7. That Guy

    Gangster

    Joined: 31 Jan 2010

    Posts: 282

    Location: UK

    Think I remember that :D

    Was the command something like:

    Code:
    bat2exe.exe test.bat test.com
    Then it converted it for you?
     
  8. marc2003

    Capodecina

    Joined: 6 Feb 2004

    Posts: 20,239

    Location: England

    isn't it pointless making an .exe when you still need to have other external files with it?
     
  9. That Guy

    Gangster

    Joined: 31 Jan 2010

    Posts: 282

    Location: UK

    Keeps Copyright info intact and makes it look a little more professional.

    I know its not ideal but I think its still better than a .BAT file.
     
  10. That Guy

    Gangster

    Joined: 31 Jan 2010

    Posts: 282

    Location: UK

    Just a quick update.

    I have got the batch file down to this now:

    Code:
    @echo off
    copy OEMLogo.bmp %windir%\system32
    regedit /s OEMLogo.reg
    I even have the .reg file installing silently.

    Just need to turn into a .exe file and I am sorted.
     
  11. That Guy

    Gangster

    Joined: 31 Jan 2010

    Posts: 282

    Location: UK

    OK now I have hit a problem :(

    It works fine as a batch file but when converted to a .exe file it does not work. What makes it strange is that it still comes up and says file copied but it does not actually copy the file. I have tried 2 .bat to .exe converters with the same result.

    Anyone have any ideas?
     
  12. cokecan

    Sgarrista

    Joined: 4 Jan 2004

    Posts: 7,662

    Location: Nottingham

    if its being run on vista and win 7 could it be something to do with admin rights?

    copying files into the windows folder or program files etc i think is denied without such rights
     
  13. That Guy

    Gangster

    Joined: 31 Jan 2010

    Posts: 282

    Location: UK

    I have just tried copying to the Windows Folder also the Program Files folder and this did not make a difference.

    I have even tried right clicking and choosing "Run as Administrator" with no luck :(

    I also have UAC disabled on my machine.
     
  14. K.C. Leblanc

    Sgarrista

    Joined: 13 Sep 2003

    Posts: 8,163

    Location: Glocestershire

    Have a look at one of the installation file generators I suggested, they should create a more profesional looking result.