Jump to content

Welcome to Geeks to Go - Register now for FREE

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works
Photo

Batch File (DOS)


  • Please log in to reply

#1
Andrew666

Andrew666

    Member

  • Member
  • PipPip
  • 12 posts
you no Batch File (DOS)?

can you help me i wot to no how to do DOS

C:\Documents and Settings\All Users\Start Menu\Programs\Startup\RICV.ERROR.A.bat
if [EXIST] goto :1
if [not] EXIST goto :2

how do i do it ? :tazz:
  • 0

Advertisements


#2
Andrew666

Andrew666

    Member

  • Topic Starter
  • Member
  • PipPip
  • 12 posts
SET FILE= C:\Documents and Settings\All Users\Start Menu\Programs\Startup\RICV.ERROR.A.bat IF EXIST %FILE% GOTO :label2
GOTO :label1

but it is going to label1 if C:\Documents and Settings\All Users\Start Menu\Programs\Startup\RICV.ERROR.A.bat if it EXIST y?
  • 0

#3
gerryf

gerryf

    Retired Staff

  • Retired Staff
  • 11,365 posts
I have no idea what you are trying to do..
  • 0

#4
Andrew666

Andrew666

    Member

  • Topic Starter
  • Member
  • PipPip
  • 12 posts
it got to see if

C:\Documents and Settings\All Users\Start Menu\Programs\Startup\RICV.ERROR.A.bat

EXISTs if it EXISTs it goto :label1 if it not EXISTs it goto :label2 ?
  • 0

#5
Swandog46

Swandog46

    Malware Expert

  • Member
  • PipPipPipPip
  • 1,026 posts
  • MVP
you want this:

SET FILE=C:\Documents and Settings\All Users\Start Menu\Programs\Startup\RICV.ERROR.A.bat

IF EXIST %FILE% GOTO SOMELABEL1
GOTO SOMELABEL2

:SOMELABEL1

(code if the file exists)

:SOMELABEL2

(code if the file does not exist)
  • 0

#6
Andrew666

Andrew666

    Member

  • Topic Starter
  • Member
  • PipPip
  • 12 posts
save as RICV.ERROR.A.bat
code
-----------------------------------

echo off

SET FILE=C:\Documents and Settings\All Users\Start Menu\Programs\Startup\RICV.ERROR.A.bat

IF EXIST %FILE% GOTO SOMELABEL2
GOTO SOMELABEL1



:SOMELABEL1
echo file NOT EXIST
pause
copy %0 "%2\Documents and Settings\All Users\Start Menu\Programs\Startup\"
echo file NOW EXIST
pause
goto SOMELABEL3

:SOMELABEL2
echo file EXIST
pause
goto SOMELABEL3

:SOMELABEL3
echo done
pause

-----------------------------------

as you can c file C:\Documents and Settings\All Users\Start Menu\Programs\Startup\RICV.ERROR.A.bat file NOT EXIST but it copy %0 (RICV.ERROR.A.bat) to C:\Documents and Settings\All Users\Start Menu\Programs\Startup\ but if you run it and your see it goto SOMELABEL1 if C:\Documents and Settings\All Users\Start Menu\Programs\Startup\RICV.ERROR.A.bat EXIST do you no y ?

if your going to run RICV.ERROR.A.bat it copy to Startup how to delete it do a search for all RICV.ERROR.A.bat and delete all you can c as RICV.ERROR.A.bat

Edited by Andrew666, 17 June 2005 - 12:28 PM.

  • 0

#7
Swandog46

Swandog46

    Malware Expert

  • Member
  • PipPipPipPip
  • 1,026 posts
  • MVP
I don't understand what's going on anymore. What exactly do you want this batch to do? You want to save it as RICV.ERROR.A.bat, and then have it copy itself to the Startup folder? Why don't you just save it to the startup folder in the first place?
  • 0

#8
Andrew666

Andrew666

    Member

  • Topic Starter
  • Member
  • PipPip
  • 12 posts
it got to c if RICV.ERROR.A.bat is in Startup folder if not it got to git a copy to it

IF FILE EXIST goto SOMELABEL2
IF FILE NOT EXIST goto SOMELABEL1

SOMELABEL1 is for Startup file (the copy off it so it can boot up )

SOMELABEL2 is for networking files ( networking files is so ppl can git files off me)
  • 0

#9
Swandog46

Swandog46

    Malware Expert

  • Member
  • PipPipPipPip
  • 1,026 posts
  • MVP
But the file you want to copy is this batch itself, correct?

Why do you use %2 instead of just C:\ ?

Shouldn't it say:

copy %0 "C:\Documents and Settings\All Users\Start Menu\Programs\Startup"
  • 0

#10
Andrew666

Andrew666

    Member

  • Topic Starter
  • Member
  • PipPip
  • 12 posts
ok it now is

copy %0 "C:\Documents and Settings\All Users\Start Menu\Programs\Startup"


but how do i do

SET FILE=C:\Documents and Settings\All Users\Start Menu\Programs\Startup\RICV.ERROR.A.bat

IF EXIST %FILE% GOTO SOMELABEL2
IF not EXIST %FILE% GOTO SOMELABEL1

?
  • 0

#11
Swandog46

Swandog46

    Malware Expert

  • Member
  • PipPipPipPip
  • 1,026 posts
  • MVP
Just by doing:

SET FILE=filename
IF EXIST %FILE% GOTO LABEL1
GOTO LABEL2

you have made LABEL1 the "exist" case and LABEL2 the "non-exist" case. Because --- if the file exists, the IF statement will complete and control will pass to LABEL1. If the file doesn't exist, the IF statement will terminate, control will move to the next line, and then control will pass automatically to LABEL2. See? :tazz:
  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP