geo411m Posted June 2, 2007 Posted June 2, 2007 I'm having a problem with my CMD file. I'm using $OEM$ folder to place a shortcut in my startup folder to run a cmd file that applys my regtweaks and then deletes its own shortcut from startup folder and reboots. unfortunately it doesn't work and after reboot the shortcut is still there starting the whole cycle again.TITLE Registry TweaksCOLOR 0FCLSECHO.ECHO Applying Registry Tweaks...REGEDIT /S %WINDIR%\INSTALL\Tweak.regECHO.ECHO All done! Now Windows Vista will reboot one last time...ECHO.ECHO -------------------------------------------------------------------------SLEEP 5DEL del /f /a /q "%SYSTEMDRIVE%\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup\StartVista.lnk"SHUTDOWN.EXE -R -F -T 5EXITany help would be greatly appreciated.
jaclaz Posted June 2, 2007 Posted June 2, 2007 (edited) 1st question:DEL del /f /a /q "%SYSTEMDRIVE%\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup\StartVista.lnk"DEL del ? Semi-random hints:What happens on a normally booted Vista if you open a command prompt and simply give the command?DEL del /f /a /q "%SYSTEMDRIVE%\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup\StartVista.lnk"Any error?Are you sure you have the privileges needed to perform the action?Can you create a "tag" file somewhere, not on %systemdrive% say in C:\temp and add to the command something like:(at the beginning)If exist C:\temp\tagfile.tag goto :EOFand something at the end like:If NOT exist C:\temp\tagfile.tag ECHO The REG tweaks have been applied > C:\temp\tagfile.tagAnd have another .cmd automatically starting from another link like:If exist C:\temp\tagfile.tag (DEL C:\temp\tagfile.tagDEL /f /a /q "%SYSTEMDRIVE%\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup\StartVista.lnk")jaclaz Edited June 2, 2007 by jaclaz
geo411m Posted June 2, 2007 Author Posted June 2, 2007 1st question:DEL del /f /a /q "%SYSTEMDRIVE%\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup\StartVista.lnk"DEL del ? Semi-random hints:What happens on a normally booted Vista if you open a command prompt and simply give the command?DEL del /f /a /q "%SYSTEMDRIVE%\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup\StartVista.lnk"opps thats one problem. even after i remove the double "del" and run the command from a normally booted vista i get "could not find". even if i run prompt as admin. i'm kinda new with scripting as you can tell.
jaclaz Posted June 2, 2007 Posted June 2, 2007 hmmm, what ATTRIButes has that file?ATTRIB "%SYSTEMDRIVE%\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup\StartVista.lnk"Maybe is hidden / system ...Besides, del /f /a /qthe /a parameters, at least in 2K/XP needs the correct attribute following, like in /a:HSRthe /q switch is unneededthe /f forces the deletion of a read only file, but only if it is not hiddenAs a general "rule of thumb" when writing batches, make them in a manner that they can be run from an open command prompt so that you have visual feedback, add to them as much PAUSE statements as you see fit to parse the output, if needed put some @Echo on and @Echo off just before and after relevant lines, to be able to check if the batch works properly, when using parameters in commands, always try with no parameters or just one at the time, double check sintax and make sure to have understood it before using parameters.A good site with help for the various commands is this one:http://www.ss64.com/nt/Always check this site:http://www.robvanderwoude.com/to learn more about sintax and to see examples of well written batches.jaclaz
Mercury_22 Posted June 3, 2007 Posted June 3, 2007 Try this DEL "%ALLUSERSPROFILE%\Microsoft\Windows\Start Menu\Programs\Startup\StartVista.lnk"
Mercury_22 Posted June 3, 2007 Posted June 3, 2007 (edited) Even better add a key in "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce" instade off a .lnk in Startup folder! using: e.g reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce" /v StartVista /t reg_sz /d "%systemdrive%\StartVista.cmd" /f Edited June 3, 2007 by Mercury_22
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