radigast Posted November 4, 2007 Share Posted November 4, 2007 (edited) I use .cmd files in WPI after each application install to cleanup the start menu/desktop/etc...However, I am having trouble with my WinRarCleanup.cmd. When called from WPI on the cd, the .cmd does not clean up the start menu shortcuts. The shortcuts still remain right where WinRar put them. I have triple-checked the path to the file in WPI, and it is correct. However, when I simply copy the .cmd file to the desktop and run it, the .cmd file does what it is supposed to and the WinRar entires in the Start Menu are moved to exactly where I want them. Every other .cmd file I use has environment variables, and they work flawlessly. I have read through the batch file guide, and searched numerous different topics on the forums, but didn't find any info. What could be causing this weird glitch?WinRARCleanup.cmd CLS @echo off TITLE CleanUp ECHO. ECHO Cleaning up Windows Installation ::Creating "Utilities" Submenu MD "%Allusersprofile%\Start Menu\Programs\Utilities\" ::Moving Shortcut to Utilities Submenu move /Y "%Allusersprofile%\Start Menu\Programs\WinRAR\WinRAR.lnk" "%Allusersprofile%\Start Menu\Programs\Utilities" ::Removing WinRar Subtree RD /S /Q "%Allusersprofile%\Start Menu\Programs\WinRAR" RD /S /Q "%Homepath%\Start Menu\Programs\WinRAR" Edited November 6, 2007 by radigast Link to comment Share on other sites More sharing options...
midi2k6 Posted November 4, 2007 Share Posted November 4, 2007 you need to create autorun.inf file for .cmd and link to the %cdromdrive% pathexample: (autorun.inf command)[autorun]OPEN=Install.cmdICON=Autorun.icoput it on CD and burn it with other files._________________________________________________________________ Link to comment Share on other sites More sharing options...
Yzöwl Posted November 4, 2007 Share Posted November 4, 2007 First of all the file cannot possibly work since the environment variable %homepath% is incorrect.If you wanted to use that variable in that situation you'd have to use %homedrive%%homepath%, which is pointless since %userprofile% already gets there.Another thing which seems a little strange is that it'd be quicker to rename the WinRAR to Utilities instead of Making Utilities copying to it then deleting WinRAR. One more thing which strikes me as odd is that you say that you've checked the paths, but I find it a little unusual for there to be WinRAR directories created under Start Menu\Programs for both All Users and Current Users. Link to comment Share on other sites More sharing options...
radigast Posted November 5, 2007 Author Share Posted November 5, 2007 First of all the file cannot possibly work since the environment variable %homepath% is incorrect.When I type %homepath% into the address bar of windows explorer, I am taken to the proper directory without fail. Furthermore, every other .cmd file I have made also has the %homepath% variable, and is called correctly when run off the cd. The WinRar .cmd file is the only one not working.If you wanted to use that variable in that situation you'd have to use %homedrive%%homepath%, which is pointless since %userprofile% already gets there.Point taken about %userprofile%. I simply did not know this variable existed, so have switched all of the %homepath% variables to %userprofile%. As mentioned before, though, %homepath% worked in every other batch file run from the cd.Another thing which seems a little strange is that it'd be quicker to rename the WinRAR to Utilities instead of Making Utilities copying to it then deleting WinRAR.Yeah, it definitely is. Thanks for the suggestion. I'm just not sure I can do that because I have made a cleanup batch file for each program, and am not sure if I can keep renaming to the Utilities folder over and over again.One more thing which strikes me as odd is that you say that you've checked the paths, but I find it a little unusual for there to be WinRAR directories created under Start Menu\Programs for both All Users and Current Users.I am 100% positive that WinRaR creates entires in both Start Menus for All Users and Current Users, otherwise I would not have put both lines in the cleanup batch file.Screenshots-->I am definltey a noob when it comes to batch files, but most of the time I am not too stupid. Thanks for the %userprofile% suggestion, though. I'll implement that rather than %homedrive% and see what happens. Link to comment Share on other sites More sharing options...
radigast Posted November 6, 2007 Author Share Posted November 6, 2007 I finally figured out why cleaning up the WinRaR start menu items was not working with the batch file I created. There were no errors in the code. The problem was that there needed to be a pause/sleep in the batch file so that WinRaR could create the Start Menu items first. The batch file was running too quickly after setup, so it was trying to move shorcut links that didn't exist yet.For those of you who use WinRaR and like to tidy up your start menu, here is a snippet from my batch file that will pause the script for 1 second. To give credit where credit is due, I got this idea from here. ::Pausing batch file for 1 second so WinRaR shortcuts move properly PING 127.0.0.1 -n 2I did not want to use sleep.exe because I did not want to see the command window. I simply hid this window by using the /HID feature in cmdow.Hope this helps someone else out there. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now