Jump to content

Problem running a batch file from winrar


Recommended Posts

Hi all. I am having some problems with a seemingly simple file. It started out as a cleanup.cmd file, but would not run for me. I could not get it to execute by itself during the install. I had decided to place the cleanup code in with my install.cmd, which is run on initial startup through the all users\startup folder. This works, but it is somewhat messy the way it is set up. I don't like it.

So I hit upon the idea of calling an executable at the end of the install. I created a cleanup.cmd, and placed it in a winrar sfx archive. The parameters for it are to install silently to the c:\ drive, and execute the cleanup.cmd after it is unpacked. However, it does not work so easily for me, and I do not understand why. I have created other executables in this fashion. I have one that unpacks a program into program files, then runs a batch file which executes the program and deletes the batch file.

That works fine, but when I use the same idea, with only the batch file, it will not work. I have tinkered with the settings a bit, trying it without executing the batch, and I still get the same error. It seems winrar does not like have nothing more than a batch file packed in the executable. I tried to throw in some redundant files, to see if that would make a difference, but it didn't. I simply cannot execute this batch file with winrar.

Does anybody have any idea what I am encountering, or if there is a way to work around this? It's getting frustrating, and I don't really want to revert to the mess, but I might just have to. I can't get any other method to work for me.

Thanks for taking the time to read this, and I do appreciate any help you can offer me. In the meantime, it's time for bed.

Goodnight all

Peace

Edited by daladim
Link to comment
Share on other sites


If all you want to do is run a cmd script from a RARSfx then here's one I've just done as an example for you. The batch file is extracted to the hardcoded path C:\ and is coded to delete itself after running. I've added an icon since most people do and the comments are visible through the WinRAR GUI.

I hope it helps!

Just extract the SFX from the attached archive!

ThisTest.7z

Link to comment
Share on other sites

Thanks for the prompt reply, guys. I downloaded the test, and ran it. I also opened it and looked at the sttings. You have it set up exactly the way I was trying it. The only difference I could see is that yours is in .cmd format, and mine was .bat format. So I changed the extension, and what do you know, it works now.

I don't know why that would make a difference, and I thought I tried it last nite as a .cmd file too, but maybe not. It was really late and I was tired. So anyway, I got it fixed. I have tested on two different PC's so far, and I am going to try the third right now.

Thanks again guy, this was driving me nuts last night!

Peace

Link to comment
Share on other sites

It seems I have encountered more problems with this simple sfx archive. I got it to work quite well actually, by itself. But when I place it in it's proper place on the disc, I cant seem to get it to execute. SO what I did, is took a few screenshots to show what happens, and I am going to upload them, along with my cleanup.exe, and the install.bat file.

The install.bat(StartXP.bat) is set to run the Cleanup.exe at the end of the install, just before reboot.

After the first screenshot was taken, I executed the cleanup.exe manually by going to it on the disc and clicking it. It ran just fine, and cleaned up everything exactly as programmed, then I rebooted the PC.

Then I took a look at the paths, and all the code, just to make sure everything was right. I noticed a small glitch in the code. I had typed "CLeanup.exe" in the Install.bat, instead of "Cleanup.exe". I wouldn't think such an oversight would matter, but hey, there is such a thing as "case" sensitive. So I fixed that, and tried again.

This time I got a similar error, but not quite. As you can see, this time it printed out the entire path to the location of StartXP.bat. I don't have a clue why it does this, and that is the problem. As you can see by these two screenshots, the Cleanup.exe does it's job cleaning up. But it won't execute via the Install.bat file like it is supposed to.

Here is the StartXP.bat file:

And here is the Cleanup.exe:

Can somebody please take a look at this stuff and tell me what I am doing wrong here? I would have to say, other than this one little error, my install is flawless. This is the only thing left to figure out.

Thanks again for all the help the people on this website have offered me, without you guys, I wouldn't have even gotten this far! :thumbup

Time for bed again

Peace

Link to comment
Share on other sites

Remove the start /wait in front of cleanup.exe in startxp.bat

and it should work.

You'll probably have to adjust the shutdown.exe line.

Edited by jbm
Link to comment
Share on other sites

To be honest with you I'd forget about wrapping the cmd inside a RARSfx leave it in the same location, (as cleanup.cmd not cleanup.exe), and run it using a call command.

I'd also remove unrequired lines from it cleanup.cmd too:

RMDIR /Q /S "%UserProfile%\Application Data\Microsoft\Internet Explorer\Quick Launch\Administrative Tools"

RMDIR /Q /S "%UserProfile%\Application Data\Microsoft\Internet Explorer\Quick Launch\General Tools"

RMDIR /Q /S "%UserProfile%\Application Data\Microsoft\Internet Explorer\Quick Launch\LiteStep"

RMDIR /Q /S "%UserProfile%\Application Data\Microsoft\Internet Explorer\Quick Launch\System Tools"

RMDIR /Q /S "%UserProfile%\Application Data\Microsoft\Internet Explorer\Quick Launch\TuneUp Utilities 2007"

RMDIR /Q /S "%UserProfile%\Application Data\Microsoft\Internet Explorer\Quick Launch\Unlocker"

I'd change the first two lines, the last four lines, learn to use switches correctly for the DEL command, learn the switches for XCOPY, learn when COPY can be used instead of XCOPY, learn how to utilize local environment variables in order to condense code and perhaps navigate the directories in order to reduce code too.

Then I'd try do reduce all those blank echo'd lines in STARTXP.BAT and finally rename it StartXP.cmd since your OS uses `Windows NT Command Scripts` not `MS-DOS Batch Files`.

I've attached something like the above, it's only been done quickly so I've maybe made some stupid mistakes, and not tidied it fully etc. but give it a go! Remember all you need to do is replace %CDROM%\Auto\Cleanup.exe with %CDROM%\Auto\Cleanup.cmd.

daladim.7z

Link to comment
Share on other sites

Thanks again for the quick replies, guys.

jbm, I'm not sure, but it seems your suggestion might be a little off. If I remove the start /wait, then wouldn't it move on to the next command, before it is done cleaning up? I would assume this is what your talking about by adjusting the shutdown command line, correct? I may try your suggestion to see if it will work, but Yzowl really went into some detail here, so I think I will turn my attention his way first.

Yzowl, I think you may have somewhat confused me in the latter part of your post.

First off, your saying that I can just call the cleanup.cmd from it's current location, with the same route I am taking, except without archiving it? This would mean that I can get rid of the command line to delete c:\cleanup.cmd, correct?

And I won't need the set CDROm stuff at the beginning either, that makes some sense.

The folders in quick launch deal, yeah, I don't understand it, but they are there. It' isn't really nessessary to delete them, as they don't show up in the quick launch, because I am running LiteStep on my install. But I don't want them there, so...

From here on out, your kind of shootin' over my head here. Removing the first two lines? The last four lines? I may not be too sure about whether or not I am utilizing the commands properly, but hey, they work! In other words, when I run the cleanup.cmd, it cleans up. I get rid of unwanted links, I move folders and links to where I want them, and I delete all the left over folders. Now, I understand you may be saying that I could do this using less space, and thus give myself a smaller file, but for now this is what I got.

Now, I have taken a quick look at the files you uploaded for me, and they are definitely different than mine. I have not seen this way of writing batch files yet, and I thank you for enlightening me. The first one I looked at was the cleanup.cmd. Quick question. Did you write these to match my old .cmd file? It does appear to be the case, and if so, I thank you very much for your time and effort. But could you explain thes files a bit for me, so that I can make the nessessary changes, if any should arise?

Specifically, I see that you may have included the lines that you thought were not needed, the ones about folders in the quick launch. I also noticed that you did this, while qouting them out, making them inactive. I would believe that I can just remove the "::" from the beginning of the lines to make them active, correct?

Now did you re-organize the code, or did you just leave it in the same order I had it? And do you know if you left anything out? I know you said you did these quickly, and there may be some mistakes, so I will look them over to compare the two.

As for the STARTXP.BAT being changed to STARTXP.CMD, does that really matter so much? It works as it is, and I'm not sure I understand your reference to my OS. I know my ID says that I am using XP 64, but I don't know why it says that. I am using 32 bit XP. Is this the difference you are referring to? and if so, am I ok using the .bat, or should I still change it to .cmd?

So now, from what I am gathering thus far, I can use the files you uploaded to replace my current files, and I can just place the cleanup.cmd file in my Auto folder. Then my STARTXP.cmd file will call the cleanup.cmd, and it will run straight off of the disc, without the need to copy it over, or delete it afterwards. Am I correct so far?

I will be looking over your files more closely after I am done with this post. I will also attempt to use them in my OS, but I would kind of like to be positive about this before I go and test things, as my test box is an antique. It's a 333mhz dell, with 128 mb of ram, so it takes like two hours or more to install this disc. That's a long time to wait to see if everything actually runs right.

I hope that I have covered all my questions here, but if not, I'll be back to ask them. Anyway, I'm off to do more testing. Thanks again for your help.

Peace :hello:

Link to comment
Share on other sites

OK, I have encountered one question about the cleanup.cmd that you sent me, yzowl. I'm gonna try something here I haven't tried yet, so bear with me. Attempting to use a codebox

Xcopy "%IEQL%" "%PROF%\Default User\Application Data\Microsoft\Internet Explorer\Quick Launch" /q /i /k /c /y

COPY "%USMP%\Utilities\Command Prompt.lnk" "%IEQL%\"
COPY "%USMP%\Internet\Internet Security\PeerGuardian 2\PeerGuardian.lnk" "%IEQL%\"
COPY "%USMP%\Utilities\Tuneup Utilities 2007\Utilities\1-Click Maintenance.lnk" "%IEQL%\"

::RMDIR /Q /S "%IEQL%\Administrative Tools"
::RMDIR /Q /S "%IEQL%\General Tools"
::RMDIR /Q /S "%IEQL%\LiteStep"
::RMDIR /Q /S "%IEQL%\System Tools"
::RMDIR /Q /S "%IEQL%\TuneUp Utilities 2007"
::RMDIR /Q /S "%IEQL%\Unlocker"

Seems to have worked.

Anyway, my question. My original cleanup was set to create my start menu and quick launch, then copy them over to the default user. From the look of the above string, it appears that you have set the quicklaunch to copy over to default user profile, then add links to the user profile, and delete those odd folders.

Can I move the XCOPY of the quick launch to a space after the links are moved, and folders deleted, or does it matter when using code in this manner? I would assume that lines are still executed in the order in which they appear, so it should be nessessary to have the quick launch copied over afterward. Am I correct in this assumption?

This is about as far as I have gotten on the examination, so I will go back to that now. Other than this question, I am understanding the code, and it looks like everything is in order, up to this point. :thumbup

Peace

Link to comment
Share on other sites

I looked through the files you uploaded, yzowl, and I made the nessessary adjustments. I un-qouted the folders I wanted deleted, and I moved the xcopy to a space after the link moves and folder delete codes. Then I placed the files in my disc, and installed it to the test box. It has just finished installing(took three and a half hours!).

All I got to say is, righteous, simply righteous, man! Thanks! Those files worked very well indeed! It installed everything the way it is supposed to, and called the cleanup.cmd at the end perfectly.

I did encounter a few problems however.

First off, It seems that I don't need the /Wait command for the noreboot.exe, in the jscript install:

ECHO         -----------------------------------------------------------------
ECHO.
ECHO JScript 5.6 Security Update for Windows XP SP1 and SP2 [KB917344]
ECHO.
ECHO -----------------------------------------------------------------

START "" /WAIT %LOCN%\WU\noreboot.exe

What happens here, is the install hangs, and I have to kill the noreboot.exe to continue.

However, I found that by deleting the stuff between START and %:

START %LOCN%\WU\noreboot.exe

I can make it install properly. I hope that this is the correct way to do this.

The only other problem is that the StartXP.cmd is not deleted at the end of the install, so it starts all over again on reboot. The path it is installed to during the initial OS install is All Users\Start Menu\Programs\Startup.

The code in the original .bat file is:

ATTRIB -R -A -S -H "%ALLUSERSPROFILE%\Start Menu\Programs\Startup\STARTXP.BAT"
DEL "%ALLUSERSPROFILE%\Start Menu\Programs\Startup\STARTXP.BAT"

So, how do I incorporate this in the new .cmd file that you wrote? I noticed that the StartXP.cmd window closes, right after it calls the cleanup.cmd, so would it be possible to just have the cleanup.cmd file delete that, and maybe even reboot the PC? then I could eliminate the end of the startxp.cmd string.

I don't see this stuff:

%MTLINE%
ECHO -----------------------
ECHO.
ECHO Rebooting in 15 seconds
ECHO.
ECHO -----------------------

When the cleanup is initiated, so I would think that can be eliminated all together.

Can I move this:

>NUL PING -n 6 127.0.0.1

SHUTDOWN.EXE -r -f -t 10 -c "Restarting Antisoft NonStep XP one last time..."
DEL %0

To the end of my cleanup.cmd? And now that I am looking at it, what does the little "DEL %0" do? Could you maybe explain to me how to go about deleting the StartXP.cmd once all is said and done?

Thanks again yzowl, for all your help.

Peace

[EDIT]

If I were to add a line to the Cleanup.cmd, Would it look like this:

DEL /F "%ASMP%\Startup\StartXP.cmd"

I'm not really sure, because the code is a bit foreign to me, but this is what I think it would look like.

Edited by daladim
Link to comment
Share on other sites

Okay, I moved the XCOPY command only to keep them together, and hadn't noticed that it was now out of order, but you are correct that the lines are run in order so if you feel you need to re-order them then you should be able to do so.

I'd like to explain how CALL works; it navigates to and runs the script, maintaining the variables etc. from the calling script and then returns to it after the called script is ended. The way that it works means that you set the StartXP.cmd to run from your Startup folder on reboot/first login. When it runs it checks that the Windows CD-ROM is still in the drive, if not it should remain in position until next time you reboot/login. when it'll try again. The DEL %0 at the end of StartXP.cmd is the instruction to delete itself and is therefore the last line. This means that only when the script has been fully run to completion will it delete itself. The only reason it is not currently running this command is that control doesn't seem to be returned to it after Cleanup.cmd has completed. (Just to be safe, because you are running it from a global location, you may wish to try replacing DEL %0 with DEL /F %0 or even as a last resort use the /A switch too!). I'm also not sure why the CALL is not working correctly, it should return to the original script when finished. Logically I would assume that the Cleanup.cmd isn't finishing for some reason, but the best way to check that is to insert a pause or message at the end and wait to see if it appears during install.

I've no idea about your hanging installer because the correct syntax for the command is to include the quotes, optionally placing a description within them.

Finally I'd strongly suggest that you use a Virtual Machine for testing all this stuff out, Microsoft, VMWare and VirtualBox all provide free ones, the latter being my preference. Using these you can create your installs a lot quicker and take snapshots to prevent you having to recover old ground too!

Link to comment
Share on other sites

OK, so due to the call command, I can't just move the deleting of the startXP.cmd and the reboot sequence to the cleanup.cmd, correct? And I should try to change the DEL $0, to DEL f/ %0, or even DEL f/ a/ %0, right? The f/ switch forces, but what is the a/ for? The call command seems to work all right, it just doesn't show the original window again.

The original window closes when cleanup starts, and after cleanup is finished, I get a little popup that informs me that windows will reboot in 15 seconds. So this all works fine, it's just that StartXP doesn't do the little printout about rebooting.

About the noreboot.exe. You say I should leave the qoutes in the code? But it is ok to delete the /WAIT command, correct? I tried it by deleting the "" /WAIT out of the code and it worked fine, but if it doesn't effect the code to have the "" in there, I can easily leave it there.

As for the Virtual machine, I have two different softwares for that purpose, but out of the three PC's I'm currently running, only one could possibly handle running it. And I don't want to install it on that one, because it's my laptop, and I would like to keep it pretty minimal on installed software. I did try virtual machine on the Pc I use for internet, it's a 1.4 gig with 512 mb of ram, but it was slower than the antique I'm currently using. So for now I think I'm just going to keep doing it this way. Not that I don't understand the virtues of a virtual machine, it's a great tool to have, it's just that at the moment I'm somewhat limited on powerful PC's

I will run a quick test with the switches you recommend, and let you know if it works.

Thanks again man, you really are a great help.

Peace

Link to comment
Share on other sites

All right, I just ran a quick test. I deleted all but the relevent code from the StartXP.cmd, and added the switches you suggested. I then placed the file in it startup folder, and ran it. It works great. Thanks for all the help man, yer my new hero! LOL!!

I'm gonna place this file on the disc, and I'll run another test tomorrow, but I have no doubt that this will work. I think all I got left to do is make some thems for windows, and throw them in with some wallpapers, and I should be finished. That is, with the exception of the ntuser.dat file I just learned about today. I want to learn more about this file, and findout how I can get it copied over to the system. It seems like it would need to be copied when I'm logged out, but could I do that at the T-12 during install? Hmmm, just thinking to myself here. I'll do some more research on that one.

Thanks a TON yzowl!! You are the greatest :thumbup

Peace :hello:

Link to comment
Share on other sites

Just as closure to your last little problem, Cmdow.exe was used to hide the cleanup window, perhaps you should unhide it again, using the /VIS switch , at the end of the cleanup.cmd or on the return to the StartXP.cmd.

Link to comment
Share on other sites

Thank you for the suggestion, yzowl, But I honestly don't see a need for it. After the cleanup.cmd, it is just confirmation through StartXP.cmd that windows is rebooting, but the shutdown window pops up and gives the same notification, so I think the rest is unnessessary. I will keep your suggestion in mind though. "/VIS" is another switch I have not heard of yet, so it could come in handy in the future.

Peace :hello:

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...