Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

Batch file problem


  • Please log in to reply
21 replies to this topic

#1 Tybudd

Tybudd

  • Members
  • 102 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:California
  • Local time:10:13 AM

Posted 23 May 2014 - 02:54 AM

I'm trying to create a batch file, but for some reason I'm getting this error (check attachment)

 

This is the batch

 

 @del C:\Program Files(x86)\World of Warcraft\Cache\WDB\enUS\creaturecache.wdb

@del C:\Program Files(x86)\World of Warcraft\Cache\WDB\enUS\npccache.wdb
@start C:\Program Files(x86)\Battle.net\Battle.net Launcher.exe
 
 
I'm sure the problem is (from the error), the SPACE right after the word 'Program', not eliminating the spaces changes the address and doesn't work either, what is to be used as a space filler?


BC AdBot (Login to Remove)

 


#2 TsVk!

TsVk!

    penguin farmer


  • Members
  • 6,236 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:The Antipodes
  • Local time:03:13 AM

Posted 23 May 2014 - 03:16 AM

you need to put quotes around the filenames, as there are spaces in there...

 

like this;

 

@del "C:\Program Files(x86)\World of Warcraft\Cache\WDB\enUS\creaturecache.wdb"


Edited by TsVk!, 23 May 2014 - 03:16 AM.


#3 czarboom

czarboom

  • Members
  • 608 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Central Texas
  • Local time:12:13 PM

Posted 23 May 2014 - 03:20 AM

spaces do not matter, but I am intrested in why your making batch that does not display the commands everything after @ which is the operator for dont display is not shown.   Also you must use different syntax depending on the DOS ver you're using. 

 

Lastly if it did work, using the del command in a batch like you have will only delete the file, not the folder it is in.  If you are trying to just delete from command line cd to the folder, and use del and the file name to remove it.


CZARBOOM 
 
"Never Stop Asking Questions, Question Your Environment, Question Your Government, above all Question Yourself.  We all lose when you Stop asking Why?

#4 TsVk!

TsVk!

    penguin farmer


  • Members
  • 6,236 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:The Antipodes
  • Local time:03:13 AM

Posted 23 May 2014 - 03:29 AM

spaces do not matter

How does the machine know that you are not putting a new command, argument or variable after a space then?

 

Quotes are very important in this sort of example, although as you noted @ is not essential.


Edited by TsVk!, 23 May 2014 - 04:02 AM.


#5 scotty_ncc1701

scotty_ncc1701

  • Members
  • 520 posts
  • OFFLINE
  •  
  • Gender:Male
  • Local time:01:13 PM

Posted 23 May 2014 - 06:34 AM

1.  Put quotes around the paths, e.g.:

@del "C:\Program Files(x86)\World of Warcraft\Cache\WDB\enUS\creaturecache.wdb"

2.  The "@" at the beginning of each line isn't needed, instead, put this at the beginning of the file, and change "@del" to "del", and @start to start:

@echo off
@cls

3.  Also suffix each "del" line with " /q" (that's a space before the /q) to prevent prompting to confirm deletion.

 

 

 

 

 

c:\TEMP02>del /?
Deletes one or more files.

DEL [/P] [/F] [/S] [/Q] [/A[[:]attributes]] names
ERASE [/P] [/F] [/S] [/Q] [/A[[:]attributes]] names

  names         Specifies a list of one or more files or directories.
                Wildcards may be used to delete multiple files. If a
                directory is specified, all files within the directory
                will be deleted.

  /P            Prompts for confirmation before deleting each file.
  /F            Force deleting of read-only files.
  /S            Delete specified files from all subdirectories.
  /Q            Quiet mode, do not ask if ok to delete on global wildcard
  /A            Selects files to delete based on attributes
  attributes    R  Read-only files            S  System files
                H  Hidden files               A  Files ready for archiving
                I  Not content indexed Files  L  Reparse Points
                -  Prefix meaning not

If Command Extensions are enabled DEL and ERASE change as follows:

The display semantics of the /S switch are reversed in that it shows
you only the files that are deleted, not the ones it could not find.

c:\TEMP02>
 



#6 czarboom

czarboom

  • Members
  • 608 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Central Texas
  • Local time:12:13 PM

Posted 24 May 2014 - 02:11 AM

I agree, I have not used batch out side of a shell in a while.  I get stupid with all the puddy time I put in, I forget stuff outside of Linux, and a shell. 

 

I asked because what you were showing looked like your trying to run a hidden delete script to jack something or someone up, and I cant tell you how to do that. 

 

But, if you go to Stackoverflow you can see what your looking for.

 

the basics assuming your using DOS and not VB or something else looks like this

 

If you're using Windows try this (assuming *full_path* is directory you want to delete in):

 

@echo off
DEL /Q full_path\a*.*

or if you want to delete files from that dir and in its subdir, try this:

@echo ff
DEL /Q /S full_path\a*.*

 

If you want it as a stand alone file you have to double click you need to shell it up or make a macro type


CZARBOOM 
 
"Never Stop Asking Questions, Question Your Environment, Question Your Government, above all Question Yourself.  We all lose when you Stop asking Why?

#7 Tybudd

Tybudd
  • Topic Starter

  • Members
  • 102 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:California
  • Local time:10:13 AM

Posted 24 May 2014 - 02:40 AM

I'm using notepad, with the file saved as .bat file.

 

This is just an icon I want to use that erases a saved file upon start up.

@echo off
@cls
del "C:\Program Files(x86)\World of Warcraft\Cache\WDB\enUS\creaturecache.wdb" /q
del "C:\Program Files(x86)\World of Warcraft\Cache\WDB\enUS\npccache.wdb" /q
start "C:\Program Files(x86)\Battle.net\Battle.net Launcher.exe" /q	

This is what I have now, and for some reason it still isn't working for me, the only thing that happens is a DOS will pop up and go away, but it doesn't erase the file nor start the launcher.exe, did I not understand 1 of you guys instructions?



#8 czarboom

czarboom

  • Members
  • 608 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Central Texas
  • Local time:12:13 PM

Posted 24 May 2014 - 03:10 AM

@echo off
DEL /Q C:\Program Files(x86)\World of Warcraft\Cache\WDB\enUS\creaturecache.wdb\a*.*

 

That is what it should look like for a one line


CZARBOOM 
 
"Never Stop Asking Questions, Question Your Environment, Question Your Government, above all Question Yourself.  We all lose when you Stop asking Why?

#9 scotty_ncc1701

scotty_ncc1701

  • Members
  • 520 posts
  • OFFLINE
  •  
  • Gender:Male
  • Local time:01:13 PM

Posted 24 May 2014 - 07:50 AM

 

I'm using notepad, with the file saved as .bat file.
 
This is just an icon I want to use that erases a saved file upon start up.

@echo off
@cls
del "C:\Program Files(x86)\World of Warcraft\Cache\WDB\enUS\creaturecache.wdb" /q
del "C:\Program Files(x86)\World of Warcraft\Cache\WDB\enUS\npccache.wdb" /q
start "C:\Program Files(x86)\Battle.net\Battle.net Launcher.exe" /q
This is what I have now, and for some reason it still isn't working for me, the only thing that happens is a DOS will pop up and go away, but it doesn't erase the file nor start the launcher.exe, did I not understand 1 of you guys instructions?
To see what is wrong, just for testing:

1. PUT "REM " (what REM and a space) in front of the @ECHO OFF and @CLS line, this will let the stuff show, for the testing.
2. At the end of the file, on it's own line put (no quote): "PAUSE"

3. # 2 will then display, "Press any key to continue...".

Now you'll see what's wrong. Once you fix it, remove the "REM " (what REM and a space) on the two lines, and optionally the "PAUSE".

1. Look at the path for the launcher, I could be wrong, but it just doesn't look quite right (I don't play/use the game).
2. On the DEL commands, you can also try " /F" (that space, then /F". This forces deletion of read only files. Please look in the syntax help I provided.

Best of luck.
 

Edited by scotty_ncc1701, 24 May 2014 - 07:55 AM.


#10 TsVk!

TsVk!

    penguin farmer


  • Members
  • 6,236 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:The Antipodes
  • Local time:03:13 AM

Posted 24 May 2014 - 06:31 PM

try this...

del /q /f "C:\Program Files(x86)\World of Warcraft\Cache\WDB\enUS\creaturecache.wdb"
del /q /f "C:\Program Files(x86)\World of Warcraft\Cache\WDB\enUS\npccache.wdb" 
start "C:\Program Files(x86)\Battle.net\Battle.net Launcher.exe"

That will run no problems... assuming the file names are correct.



#11 Tybudd

Tybudd
  • Topic Starter

  • Members
  • 102 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:California
  • Local time:10:13 AM

Posted 26 May 2014 - 02:29 PM

Trying this is CMD prompt it tells me that the system can't find the file as if the address is wrong, is it possible that it's encrypted?



#12 TsVk!

TsVk!

    penguin farmer


  • Members
  • 6,236 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:The Antipodes
  • Local time:03:13 AM

Posted 26 May 2014 - 03:45 PM

The file probably doesn't exist. (the address is actually wrong),

 

Or, try running the .bat as administrator.



#13 scotty_ncc1701

scotty_ncc1701

  • Members
  • 520 posts
  • OFFLINE
  •  
  • Gender:Male
  • Local time:01:13 PM

Posted 26 May 2014 - 06:57 PM

You didn't specify the files in question.  However, if it's:

 

"C:\Program Files(x86)\Battle.net\Battle.net Launcher.exe"

 

The "Battle.net\Battle.net Launcher.exe" in the path doesn't look right, might it be: "C:\Program Files(x86)\Battle.net\Launcher.exe"?

 

Best of luck.


Edited by scotty_ncc1701, 26 May 2014 - 06:57 PM.


#14 JohnnyJammer

JohnnyJammer

  • Members
  • 1,117 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:QLD Australia
  • Local time:03:13 AM

Posted 26 May 2014 - 07:29 PM

Something like this should work

@echo off
if exist "C:\Program Files(x86)\World of Warcraft\Cache\WDB\enUS\creaturecache.wdb" del "C:\Program Files(x86)\World of Warcraft\Cache\WDB\enUS\creaturecache.wdb" /f /q
if exist "C:\Program Files(x86)\World of Warcraft\Cache\WDB\enUS\npccache.wdb" del "C:\Program Files(x86)\World of Warcraft\Cache\WDB\enUS\npccache.wdb" /f /q
start "C:\Program Files(x86)\Battle.net\Battle.net Launcher.exe"
pause

I aint tested it but just did it in notepad.


Edited by JohnnyJammer, 26 May 2014 - 07:34 PM.


#15 Tybudd

Tybudd
  • Topic Starter

  • Members
  • 102 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:California
  • Local time:10:13 AM

Posted 26 May 2014 - 10:23 PM

You didn't specify the files in question.  However, if it's:

 

"C:\Program Files(x86)\Battle.net\Battle.net Launcher.exe"

 

The "Battle.net\Battle.net Launcher.exe" in the path doesn't look right, might it be: "C:\Program Files(x86)\Battle.net\Launcher.exe"?

 

Best of luck.

 

Specify them how? Excuse my ignorance

 

for the path, I just went to the properties of the shortcut on my desktop, and copied the "Target" which was that, I checked the physical location, in the Start>Run(Search) bar, and it goes to that item, so the address' seem legit

The file probably doesn't exist. (the address is actually wrong),

 

Or, try running the .bat as administrator.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users