Anyone Good With Batch Files -(commands)?

Discussion in 'other software & services' started by DasFox, Sep 29, 2008.

Thread Status:
Not open for further replies.
  1. DasFox

    DasFox Registered Member

    Joined:
    May 5, 2006
    Posts:
    1,825
    I've made a batch file and converted it to an .exe, but when I run the .exe it crashes only when I run number 1 for the ccleaner.

    I've been playing with the batch commands thinking I got it down, but it still crashes.

    This is how you can duplicate the crash, you click on 1. to Open CCleaner, then run the ccleaner, do a clean with it, then close it, and then back at the Program Launcher window type 1 again and hit enter, this time the window will shutdown...

    It's the only place in the code that causes a crash, and I don't know why this happens as a .exe, but running the program as a .bat this does not happen.

    If anyone can figure this out I'd greatly appreciate it. This is a cool little app for easy launching and I'd like to get this bug worked out if I can.

    I used Bat_To_Exe_Converter to do the converting, but with other convert apps I had the same problem as well.

    THANKS... :)

    Here is the download for the .exe:

    http://www.mediafire.com/download.php?jkymmg4jdgy

    Here is the batch code from the .bat:

    color 1f
    echo off
    :menu
    cls
    title Program Launcher v1.0 (Created by AlohaPCs)
    echo.
    echo ***** Welcome To Program Launcher v1.0 *****
    echo.
    echo The Program Launcher makes it easy to run all of your favorite programs.
    echo.
    echo Type a number at the flashing cursor below then hit 'Enter' on your
    echo keyboard to start the program.
    echo.
    echo.
    echo Pick A Program Below To Start:
    echo.
    echo 1. Open CCleaner
    echo 2. Open Control Panel
    echo 3. Open Disk Defragmenter
    echo 4. Open Disk Management
    echo 5. Open Msconfig
    echo 6. Open Avira AntiVir Personal
    echo 7. Open Search Results
    echo 8. Open Windows Firewall
    echo 9. Quit
    echo.
    echo.

    set choice=
    set /p choice= Type Your Number Choice Here:
    echo.
    if not '%choice%'=='' set choice=%choice:~0,1%
    if '%choice%'=='9' goto End
    if '%choice%'=='8' goto wf
    if '%choice%'=='7' goto sr
    if '%choice%'=='6' goto av
    if '%choice%'=='5' goto msc
    if '%choice%'=='4' goto dskm
    if '%choice%'=='3' goto dd
    if '%choice%'=='2' goto cp
    if '%choice%'=='1' goto cc

    echo.
    echo "%choice%" is not a valid option - try again
    echo.
    pause
    goto menu

    :cc
    cls
    start ccleaner.exe
    goto menu

    :cp
    cls
    start control.exe
    goto menu

    :dd
    cls
    start dfrg.msc
    goto menu

    :dskm
    cls
    start diskmgmt.msc
    goto menu

    :msc
    cls
    start msconfig.exe
    goto menu

    :av
    cls
    start C:\"Program Files"\Avira\"AntiVir PersonalEdition Classic"\avcenter.exe
    goto menu

    :wf
    cls
    start firewall.cpl
    goto menu

    :sr
    cls
    type nul > %temp%\1.fnd & start %temp%\1.fnd & del /q /f "%temp%\1.fnd"
    goto menu

    :End
    set choice=
    exit
     
    Last edited: Sep 29, 2008
  2. majoMo

    majoMo Registered Member

    Joined:
    Aug 31, 2007
    Posts:
    994
    @ DasFox,

    Tested.

    ( ... ) It's the only place in the code that causes a crash, and I don't know why this happens as a .exe, but running the program as a .bat this does not happen. ( ... )

    It seems that the annoyance is:

    - The .exe needs to create these temp files to work: "b2e.dll" and "Program Launcher.bat". When you run CCleaner and you "do a clean with it" these temp files are deleted and your .exe can't work anymore... To see these files in the temp folder try this: run your .exe, open CCleaner, uncheck all items in it, and check Windows > System > Temporary Files. Click in "Analyze" button, now you can see such temp files.

    - Like the .bat file doesn't use temp files, the annoyance doesn't come out.

    So the problem isn't the code.
     
  3. Sully

    Sully Registered Member

    Joined:
    Dec 23, 2005
    Posts:
    3,719
    hmm. I think your efforts are great, because batch can be a very handy tool to use with MS products. I think that maybe you should take a look at AutoIt if you want to do the kind of stuff that your batch is intended for. AutoIt will give you a greater power, and you can have a nice simple GUI to boot. As for an .exe, I was intially turned on by AutoIt because you can compile your script into an .exe, and pass it around. There are no needed files to use it. Of course, that also is the beauty of batch, it just works.

    Here is my menu that is quick and simple I posted over at the AutoIt forums. Maybe you like it, maybe not, but it should give you an idea of maybe what can be done with it.

    http://www.autoitscript.com/forum/index.php?showtopic=78028&hl=minimalists

    Sul.
     
  4. axial

    axial Registered Member

    Joined:
    Jun 27, 2007
    Posts:
    479
    AFAIK ".bat" uses the older 16-bit command.exe, as opposed to ".cmd" which uses the 32-bit cmd.exe, at least on NT-based operating systems. Could that be causing some problem once compiled? There are many references to the difference by googling "bat vs. cmd".
     
  5. DasFox

    DasFox Registered Member

    Joined:
    May 5, 2006
    Posts:
    1,825

    Oh crap great.... :(

    Anyway around this with the .exe?

    The other thing I forgot is to set ccleaner options at, 'only delete temp files 48 hrs older, at least this is a temporary solve... :)

    THANKS




    I have no coding experience, I just want something simple. I don't want to spend my life learning how to make a .exe...

    THANKS
     
    Last edited: Sep 29, 2008
  6. Cerxes

    Cerxes Registered Member

    Joined:
    Sep 6, 2005
    Posts:
    581
    Location:
    Northern Europe
    @Sully: This AutoIt tool really has some cool automation features. Even if I´ve heard about it before, I´ve never checked it out since there are a lot of alternative script languages around. But reading the site briefly, it sounds as an interesting alternative that I will learn more about when I have some spare time.

    @DasFox: You don´t need to be a code monkey when it comes to learning a script language. If you have the interest, it should be rather easy. Google around and you will see several sites that will learn you the basics in several script languages. W3schools is one of the better ones, and there are several others as well.

    /C.
     
  7. DasFox

    DasFox Registered Member

    Joined:
    May 5, 2006
    Posts:
    1,825
    Yeah but I haven't the time to learn this now, other computer things I must do instead...

    All I want is to make a simple program launcher like the batch code converted over into a GUI....

    Maybe someone can whip something up or knows of a sample I can use to build from...

    THANKS
     
  8. DasFox

    DasFox Registered Member

    Joined:
    May 5, 2006
    Posts:
    1,825
  9. Sully

    Sully Registered Member

    Joined:
    Dec 23, 2005
    Posts:
    3,719
    @DasFox

    Coding can be easy, as batch is pretty easy. Creating complex batch files are an art form IMO. I mention AutoIt because it is a simple language with a very active forum, and many examples. I understand your position, but let me give you a very small example of how it might start.

    ; first declare variable
    $ccPath = 'c:\Program Files\ccleaner\ccleaner.exe'

    ; next this is option 1 from some sort of menu (hint: simple input box ?? )
    $answer = InputBox("Choises are x, y, z or 1,2,3")

    ; so no you could run through the 'answers', doing a specific on each
    If $answer = 'x' Then
    Run('app.exe')
    ElseIf $answer = 'y' Then
    Run('app.exe')
    ElseIf $answer = 'z' Then
    Run('app.exe')
    ElseIf $answer = '1' Then
    Run('app.exe')
    ElseIf $answer = '2' Then
    Run('app.exe')
    ElseIf $answer = '3' Then
    Run($ccPath)
    EndIf

    That is very very basic, but that is the basics of scripting. Simple logic. Should you wish to pursue this, the example above could easily get you started with something basic and funtional.

    Sul.
     
  10. Sully

    Sully Registered Member

    Joined:
    Dec 23, 2005
    Posts:
    3,719
    Also DasFox, if all you need is something to launch your stuff, why don't you try out my menu in the link. I use it for everything now.

    If you want control panel and things like that, I also have a tool that will build up your 'my computer' context menu with lot's o' goodies. I use that a lot as well. In short, if you don't want to code anything, I may have already done what you need. And no bloat, guaranteed. Just simple and efficient.

    Sul.
     
  11. Sully

    Sully Registered Member

    Joined:
    Dec 23, 2005
    Posts:
    3,719
    It is my favorite so far, because of the .exe part. There are perhaps more powerful languages for certain applications, as any perl monk could witness to :)

    I am suprised by just how many 'tools' are available that use this language. Probably the most notable that I know of would be Siginets updater for RyanVM's update packs.

    Sul.
     
  12. DasFox

    DasFox Registered Member

    Joined:
    May 5, 2006
    Posts:
    1,825

    I downloaded both files and I don't get what to do with either of them. I thought we are talking about AutoIT v3 scripts so that I can put them in the editor or run them, and then compile them is all...

    To much work here for me, LOL, I need a simple 1,2,3 is all, don't have time to learn all of this for now, BUT thanks... :)
     
    Last edited: Sep 30, 2008
  13. Sully

    Sully Registered Member

    Joined:
    Dec 23, 2005
    Posts:
    3,719
    NP. But, you don't expect a program to know what you want to do it you don't tell it. If you want an easy solution to your problem, there are many to choose from out there that is for sure.

    As for mine, it is just a method to invoke whatever you put into an .ini file. There is a builder.exe, which goes through your Program Files directory and returns any .exe's that exist also in the build.ini. This way you can pre-populate all of your .exe's that you will normally be looking for, as this way you can use it on further OS installs, or pass it along to a friend, sort of pre-done. When the checkbox list is returned, what you check is then 'built' and you have a basic list of 'programs' in a menu that you can start.

    Then you can run the menu all the time (I do) and at any time use your mouse or a special key combination to bring it 'up'. The .ini file that is made intially is full of example syntax. But basically, you set a menu name and then the .exe (with it's path) to run. You can edit the .ini file easily, reload the menu to see changes, and I even built a small GUI window to accept drag and drop the .exe for quick menu making.

    I say, to find a program starting application that already knows what you want to start is not easy to find :) . If you want a very easy way to launch nearly any .exe you want, my tool will do it. The best part of it is you can also disable network devices, and quickly change your gateway (router) for convenience, as well as bring the menu to where your mouse is, much like right clicking for a context menu.

    Just my input anyway. Cheers.

    Sul.
     
  14. Sully

    Sully Registered Member

    Joined:
    Dec 23, 2005
    Posts:
    3,719
    And for the sake of making it easy as 1,2,3 here is something you can do I am sure.

    Code:
    ; the semicolon means the line is commented
    
    ; fill in your $app variables with how many you need
    ; and the full path enclosed in either single or double quotes
    $app1 = 'c:\program files\windows media player\wmplayer.exe'
    $app2 = 'C:\Program Files\Internet Explorer\iexplore.exe'
    
    ; create a simple input box with all your values to choose from
    $answer = InputBox('Choose','1 for Media Player' & @CRLF _
    		& '2 for IE' & @CRLF _
    		& '3 for more etc',1)
    
    ; go through your answers, launching certain $app for answer
    If $answer = '1' Then
    	ShellExecute($app1)
    ElseIf $answer = '2' Then
    	ShellExecute($app2)
    EndIf
    Simply follow the pattern in the input box of
    & '6 for app.exe' & @CRLF _
    for as many as you want, then continue with the ElseIf statements until you fill it up with what you want. No guarantees that the ShellExecute function will execute all your stuff without issues, as there are more parameters than just the .exe, but this should work very easily. Download AutoIt v3.x.x.x and then you can run this or compile it.

    Sul.
     
  15. DasFox

    DasFox Registered Member

    Joined:
    May 5, 2006
    Posts:
    1,825
    THANKS Sully

    At this point in time all I need to do is add a menu with 'File' - 'Exit' and then something else like 'Info' - About that pops up a small window that I can put in some info about the program....

    I'll keep digging for samples...

    THANKS

    P.S. This is what I have so far:

    http://img523.imageshack.us/my.php?image=appcx7.jpg
     
    Last edited: Sep 30, 2008
  16. Sully

    Sully Registered Member

    Joined:
    Dec 23, 2005
    Posts:
    3,719
    If you want to do drop down menu's like File>Exit, then you get into GUI, which is quite a bit more than just a logical If / ElseIf loop. PM me if you need help. Glad to lend a hand.

    Sul.

    Edit: You should download Scite from the AutoIt download section. Getting into GUI with AutoIt is not hard, but color coding and folding will help you immensely. In scite also you will find Koda, which is a tool to help lay out your GUI. Both very valuable additions to help make stuff.
     
    Last edited: Sep 30, 2008
  17. DasFox

    DasFox Registered Member

    Joined:
    May 5, 2006
    Posts:
    1,825
    THANKS man PM sent... :D
     
Thread Status:
Not open for further replies.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.