1. You are viewing our forum as a guest. For full access please Register. WindowsBBS.com is completely free, paid for by advertisers and donations.

Bat file does not start

Discussion in 'Windows 7' started by wahlroot, 2012/01/26.

  1. 2012/01/26
    wahlroot

    wahlroot Inactive Thread Starter

    Joined:
    2002/08/15
    Messages:
    546
    Likes Received:
    1
    I made a Bat file to start at Bootup to erase Temp files. This works in XP in C: The only way it works in Win7 is if I Click the Bat file not Bootup. I would like it to happen at Bootup.
     
  2. 2012/01/26
    Steve R Jones

    Steve R Jones SuperGeek Staff

    Joined:
    2001/12/30
    Messages:
    12,285
    Likes Received:
    249
    When you run it manually - are you prompted for any sort of approval?

    You could try renaming it from .bat to .cmd to see if that helps.
     

  3. to hide this advert.

  4. 2012/01/26
    wahlroot

    wahlroot Inactive Thread Starter

    Joined:
    2002/08/15
    Messages:
    546
    Likes Received:
    1
    No approval callled for. I did change .bat to .cmd and it ran at Bootup. I then changed back to .bat and it ran at bootup. I do not know why, but I will leave It there for now. Thanks.
     
  5. 2012/01/28
    Kingman

    Kingman Well-Known Member

    Joined:
    2002/01/17
    Messages:
    78
    Likes Received:
    1
    Wahlroot, I have four batches that start during Boot/Reboot in ME. So far I haven't found how to establish them in W7. What's the path for where you put your batch? (And I hope we're talking about the same thing.)
     
  6. 2012/01/29
    wahlroot

    wahlroot Inactive Thread Starter

    Joined:
    2002/08/15
    Messages:
    546
    Likes Received:
    1
    My .bat file goes into C: It worked in XP. I hope it works now in WIN7.
     
  7. 2012/01/29
    wahlroot

    wahlroot Inactive Thread Starter

    Joined:
    2002/08/15
    Messages:
    546
    Likes Received:
    1
    I can now Click the .bat file and I can see it operate and nothing happens. I can send it through Bootup and I can not see it operate and nothing happens. I am back where I was.
    I think someone has made changes to .bat files and did not tell me.
     
  8. 2012/01/29
    Kingman

    Kingman Well-Known Member

    Joined:
    2002/01/17
    Messages:
    78
    Likes Received:
    1
    I copied a batch from ME, put it in C:. It ran, did what it should, and disappeared. Is that what's happening to you? And are we talking about the same thing---Name.bat is what I use, with plain text in it (DIR B*.*) to list all directories starting with B.
     
  9. 2012/01/30
    TonyT

    TonyT SuperGeek Staff

    Joined:
    2002/01/18
    Messages:
    9,068
    Likes Received:
    396
    Post the code.
     
  10. 2012/01/30
    wahlroot

    wahlroot Inactive Thread Starter

    Joined:
    2002/08/15
    Messages:
    546
    Likes Received:
    1
    Here is the .bat file
    @IF ERRORLEVEL 1 PAUSE
    @ECHO Off

    rd /s /q "c:\Users\Mine\AppData\Local\Temp "
    MD "c:\Users\Mine\AppData\Local\Temp "
    rd /s/ q "c:\Users\Mine\AppData\Local\History "
    MD "c:\Users\Mine\AppData\Local\History "
    rd /s /q "C:\Temp "
    MD "c:\Temp\ "
    rd /s /q "C:\Windows\temp "
    MD "C:\Windows\Temp "
     
  11. 2012/02/01
    TonyT

    TonyT SuperGeek Staff

    Joined:
    2002/01/18
    Messages:
    9,068
    Likes Received:
    396
    This should work for any user account:

    Code:
    @echo off
    echo Remove temporary files:
    pause
    RD /s/q  "%USERPROFILE%\AppData\Local\Temp "
    MD  "%USERPROFILE%\AppData\Local\Temp "
    RD /s/q  "%USERPROFILE%\AppData\Local\History "
    RD /s/q  "%SystemDrive%\Temp "
    MD  "%SystemDrive%\Temp "
    RD /s/q   "%SystemRoot%\temp "
    MD  "%SystemRoot%\temp "
    pause
    Added echo & pause so can see what the commands are actually doing. Also, no need for MD History, it will get auto-generated by Windows.

    Make a shortcut to the cmd file and then you can set it to Runas Administrator. Use the shortcut to launch the script.

    The script may fail if explorer.exe is running, thus may need to add these at beginning and end: (if History index.dat has been created)
    Code:
    pause
    taskkill /f /im explorer.exe
    xxxxx
    xxxxx
    start explorer.exe
    pause
    
     
  12. 2012/02/01
    wahlroot

    wahlroot Inactive Thread Starter

    Joined:
    2002/08/15
    Messages:
    546
    Likes Received:
    1
    TonyT! I started your .bat file with explore.exe code. I did not work with Bootup. I then Clicked .bat file and got this cmd.exe.

    Success: The process "explorer.exe" with PID 1944 has been terminated
    C:\Users\Mine\Appdata\local\Temp\IswTmp|logs - The directory is not empty.
    C:\Users\Mine\Appdata\local\Temp\`DF213B769EA30810d.TMP -The process cannot access the file because it is being used by another process.
    A subdirectory or file C:\Users\Mine\AppData\local\Temp already exists.
    The system cannot find the file specified.
    C:\Windows\Temp\ZLT02a16.tmp - The process cannot access the file because it is
    being used by another process.
    A subdirectory or file C:\Windows\temp\already exists.
    Press any key to continue ...
     
  13. 2012/02/01
    TonyT

    TonyT SuperGeek Staff

    Joined:
    2002/01/18
    Messages:
    9,068
    Likes Received:
    396
    You'll have to find out what processes are running that are using those files, then kill them first.

    And it wiil probably work if create a shortcut that runs with admin rights, then run it via the registry before explorer loads, such as the winlogon key.
     
  14. 2012/02/02
    wahlroot

    wahlroot Inactive Thread Starter

    Joined:
    2002/08/15
    Messages:
    546
    Likes Received:
    1
    I have found many processes that cannot be deleted because they are attached to something that will not let them loose. I do not know how to let them go. I now put the .bat file on Startup on Programs on the Start Menu. It is not perfect, but is better than nothing. Bootup will do.
     
  15. 2012/02/03
    Steve R Jones

    Steve R Jones SuperGeek Staff

    Joined:
    2001/12/30
    Messages:
    12,285
    Likes Received:
    249
    Having your browser open when you run the bat file could cause the errors.
     
  16. 2012/02/03
    TonyT

    TonyT SuperGeek Staff

    Joined:
    2002/01/18
    Messages:
    9,068
    Likes Received:
    396
    I think it would be better to run the script at shutdown because many of the interfering processes might already have been killed.

    start > run > gpedit.msc > Computer Configuration > Windows Settings > Scripts > Shutdown > add shortcut to the script.

    Keep the pause lines so can see what's occurring.

    Another solution would be to setup a scheduled task to run at Start Up and allow the job to run when the user isn't logged on.
     
  17. 2012/02/03
    wahlroot

    wahlroot Inactive Thread Starter

    Joined:
    2002/08/15
    Messages:
    546
    Likes Received:
    1
    The .bat file is in C: and seems to work almost all right. Some things do not.

    C:\>pause
    Press any key to continue . . .
    C:\>rd /s /q "c:\Users\MyComp\AppData\Local\Temp "- access is denied
    c:\Users\Mine\AppData\Local\Temp\~DFA54B35B32907E37C.TMP - The process cannot
    access the file because it is being used by another process.
    C:\>MD "c:\Users\Mine\AppData\Local\Temp "
    A subdirectory or file c:\Users\Mine\AppData\Local\Temp already exists.
    C:\>rd /s /q "C:\Temp "
    C:\>MD "c:\Temp\ "
    C:\>rd /s /q "C:\Windows\temp "
    C:\Windows\temp\ZLT0789f.TMP - The process cannot access the file because it is
    being used by another process.
    C:\>MD "C:\Windows\Temp" A subdirectory or file C:\Windows\Temp already exists.
    C:\>DEL /s /q "C:\Users\Mine\AppData\Local\Opera\Opera\cache\*.* "
    C:\>del /s /q "C:\Users\Mine\AppData\Roaming\Opera\Opera\Profile\vlink4.dat "
    Deleted file - C:\Users\Mine\AppData\Roaming\Opera\Opera\Profile\vlink4.dat
    C:\>Copy /y "C:\PROGRA~1\Opera\Opera1\vlink4.dat" "C:\Users\Mine\AppData\
    Roaming\Opera\Opera\Profile" 1 file(s) copied.
    C:\>DEL /s /q "C:\Users\Mine\AppData\Opera\Opera\Profile\global.dat "
    The system cannot find the path specified.
    C:\>Copy /y "C:\PROGRA~1\Opera\Opera1\global.dat" "C:\Users\Mine\AppData\Opera
    \Opera\Profile" The system cannot find the path specified. 0 file(s) copied.
    C:\>DEL /s /q "C:\Users\Mine\AppData\Roaming\Opera\Opera\global_history.dat "
    Deleted file - C:\Users\Mine\AppData\Roaming\Opera\Opera\global_history.dat
    C:\>Copy /y "C:\PROGRA~1\Opera\Opera1\global_history.dat" "C:\Users\Mine\
    AppData\Roaming\Opera\Opera" 1 file(s) copied.
    C:\>DEL /s /q "C:\Users\Mine\AppData\Roaming\Opera\Opera\Profile\opera.dir "
    Could Not Find C:\Users\Mine\AppData\Roaming\Opera\Opera\Profile\opera.dir
    C:\>Copy /y "C:\PROGRA~1\Opera\Opera1\opera.dir" "C:\Users\Mine\AppData\
    Roaming\Opera\Opera\Profile" The system cannot find the file specified.
    C:\>DEL /s /q "C:\Users\Mine\AppData\Roaming\Opera\Opera\Profile\Cookies4.dat "
    Deleted file - C:\Users\Mine\AppData\Roaming\Opera\Opera\Profile\cookies4.dat
    C:\>Copy /y "C:\PROGRA~1\Opera\Opera1\Cookies4.dat" "C:\Users\Mine\AppData\
    Roaming\Opera\Opera\Profile" 1 file(s) copied.
    C:\>DEL /s /q "C:\Users\Mine\AppData\Roaming\Opera\Opera\Profile\Images\*.* "
    C:\>DEL /s /q "C:\Users\Mine\AppData\Local\Opera\Opera\cache\*.* "
    C:\>DEL /s /q "C:\Users\Mine\AppData\Local\Opera\Opera\icons\*.* "
    C:\>REM start explorer.exe
    C:\>pause
    Press any key to continue . . .
     
  18. 2012/02/04
    TonyT

    TonyT SuperGeek Staff

    Joined:
    2002/01/18
    Messages:
    9,068
    Likes Received:
    396
    Try running at startup using gpedit.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.