Jump to content

Runonce Batch file problem(s)


Recommended Posts

I'm having problems with a couple of batch files that I'm running with runonce in xp:

cd "C:\Documents and Settings\Administrator\Desktop\" && rd /s . /q && cd "C:\Documents and Settings\All Users\Desktop\" && rd /s . /q && cd C:\Windows\system32\ && EmptyRecycleBin.exe /q

When I run it off the cd, nothing happens. When I copy to a folder (ex. My Documents) it deletes the icons from Administrator/Desktop, but not from All Users/Desktop.

The other problem I had was with this .bat file:

cd C:\AstonSettings\ && move Aston.7z "C:\Documents and Settings\Administrator\Application Data\Aston\" && cd "C:\Documents and Settings\Administrator\Application Data\Aston\" && 7z x Aston.7z && del Aston.7z && rd /s C:\AstonSettings\ /q

When I logon for the first time, I find that nothing has happened. When I copy the .bat file to the Desktop and run it, It works fine.

Link to comment
Share on other sites


Because this question was posted as a non-related reply to a two year old WPI forum topic, we could possibly assume that you're using WPI.

However we need to know the CD structure where all the pertinent files are placed and the methods you are using to attempt to run the files if you wish us to help solve your problem(s).

Additionally those are poor attempts at Windows NT Command Scripts, the echoing is visible, you don't appear to know the meaning of a 'double ampersand', you are changing directories pointlessly and could have better utilised the 7z commandline options.

Here are a couple of examples of your .cmd files, not .bat, re-done:

@Echo off
For /d %%# In ("%AllUsersProfile:All Users=%*") Do (
Pushd %%#\Desktop&&2>Nul Rd/s/q .&Popd)
EmptyRecycleBin.exe /q

If I've understood correctly the above script is intended to Remove all Files, Directories and Sub-Directories located on the Desktops of your users. It will then use your 3rd party utility located in %Path% using its /q switch.

@7z x %SystemDrive%\AstonSettings\Aston.7z -o"%AppData%\Aston"&&(
@Rd/s/q %SystemDrive%\AstonSettings)

This example will extract your archive, using 7z located in %Path%, to your chosen location and then delete itself and its parent directory.

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...