Jump to content

deleting shortcuts using CMD


Recommended Posts

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 Tweaks
COLOR 0F

CLS

ECHO.
ECHO Applying Registry Tweaks...
REGEDIT /S %WINDIR%\INSTALL\Tweak.reg

ECHO.
ECHO All done! Now Windows Vista will reboot one last time...

ECHO.
ECHO -------------------------------------------------------------------------

SLEEP 5

DEL del /f /a /q "%SYSTEMDRIVE%\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup\StartVista.lnk"

SHUTDOWN.EXE -R -F -T 5

EXIT

any help would be greatly appreciated.

Link to comment
Share on other sites


1st question:

DEL del /f /a /q "%SYSTEMDRIVE%\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup\StartVista.lnk"

DEL del ? :unsure:

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 :EOF

and something at the end like:

If NOT exist C:\temp\tagfile.tag ECHO The REG tweaks have been applied > C:\temp\tagfile.tag

And have another .cmd automatically starting from another link like:

If exist C:\temp\tagfile.tag (
DEL C:\temp\tagfile.tag
DEL /f /a /q "%SYSTEMDRIVE%\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup\StartVista.lnk"
)

jaclaz

Edited by jaclaz
Link to comment
Share on other sites

1st question:
DEL del /f /a /q "%SYSTEMDRIVE%\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup\StartVista.lnk"

DEL del ? :unsure:

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.

Link to comment
Share on other sites

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 /q

the /a parameters, at least in 2K/XP needs the correct attribute following, like in /a:HSR

the /q switch is unneeded

the /f forces the deletion of a read only file, but only if it is not hidden

As 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

Link to comment
Share on other sites

Even better add a key in "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce" instade off a .lnk in Startup folder! :thumbup using: e.g reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce" /v StartVista /t reg_sz /d "%systemdrive%\StartVista.cmd" /f

Edited by Mercury_22
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...