Specialty Forums
Security and Virus
General Hardware
CPUs/Overclocking
Networking
Digital Photo/Video
Office Software
PC Gaming
Console Gaming
Programming
Database
Web Development
Digital Home

General Forums
Windows XP
Windows Vista
Windows 95/98
Windows Me
Windows NT
Windows 2000
Win Server 2008
Win Server 2003
Windows 3.1
Linux
PDAs
BeOS
Novell Netware
OpenVMS
Solaris
Disk Op. System
Unix
Mac
OS/2

Drivers
Driver Scan
Driver Forum

Software
Automatic Updates

BIOS Updates

My Computing.Net

Solution Center

Free IT eBook

Howtos

Site Search

Message Find

RSS Feeds

Install Guides

Data Recovery

About

Home
Reply to Message Icon Go to Main Page Icon

Bat run comnd once then nver again.

Original Message
Name: Geralds Mod
Date: November 16, 2007 at 19:22:07 Pacific
Subject: Bat run comnd once then nver again.
OS: win xp
CPU/Ram: centrinio duo
Model/Manufacturer: dell inspirion e1505
Comment:
Sorry about the spelling. Couldn't fit the whole word.

Anyway, how would you get a batch file to run a command, then never run that section again or delete that section of the batch file.

I'll show you what I mean. This is my batch.

@echo off
Title Sound in firefox
type nul > "C:\Program Files\Mozilla Firefox\a.dll"
echo Push "D" to disable sound in firefox.
echo Push "E" to enable sound in firefox.
echo.
set input=
set /p input=
if %input%==d goto d
if %input%==e goto e
:d
@echo off
cd "C:\WINDOWS\system32"
rename "C:\Program Files\Mozilla Firefox\a.dll" "msacm32.dll"
cls
echo Sound is Disabled.
echo Please restart your Firefox browser.
echo (This is required in order for sound to be disabled)
ping localhost -n 4 >nul
goto end

:e
@echo off
cd "C:\WINDOWS\system32"
rename "C:\Program Files\Mozilla Firefox\msacm32.dll" "a.dll"
cls
echo Sound is Enabled in firefox.
ping localhost -n 2 >nul
goto end

:end
end

The line that says

type nul > "C:\Program Files\Mozilla Firefox\a.dll"

needs to run only once. How do i do that?


Report Offensive Message For Removal


Response Number 1
Name: Geralds Mod
Date: November 16, 2007 at 19:31:51 Pacific
Subject: Bat run comnd once then nver again.
Reply: (edit)
Oh and by once I mean the first time I double click it, it runs. The second time I start it, it doesn't run that command.

Report Offensive Follow Up For Removal

Response Number 2
Name: Geralds Mod
Date: November 16, 2007 at 20:31:38 Pacific
Subject: Bat run comnd once then nver again.
Reply: (edit)
Never mind I need something else.

Report Offensive Follow Up For Removal

Response Number 3
Name: Mechanix2Go
Date: November 17, 2007 at 13:04:50 Pacific
Subject: Bat run comnd once then nver again.
Reply: (edit)
I don't get where you're headed but the simple way to run a BAT section only once:

::== my.bat
@echo off > #-#
:: do stuff
if exist #-# goto :second
:: this gets done only on first run
:second
:: do other stuff
================================

Other comments:

No point in turning echo off more than once.

No point changing to a directory then doing a REN in another..

Instead of creating an END, use the built-in :eof


You can simplify the user input and branching to this:
==================
set /p tag=choose D [disable] or E [enable]
goto :%tag%
:D
here's D
:E here's E
=====================


=====================================
If at first you don't succeed, you're about average.

M2



Report Offensive Follow Up For Removal




Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Bat run comnd once then nver again.

Comments:

 
  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 


Data Recovery Software




acer 312T BIOS problem

K7 Turbo possible max fsb?

Pc anywher problem

WinFLP & OE/Outlook2003

Computer resets after a few minutes


The information on Computing.Net is the opinions of its users. Such opinions may not be accurate and they are to be used at your own risk. Computing.Net cannot verify the validity of the statements made on this site. Computing.Net and Computing.Net, LLC hereby disclaim all responsibility and liability for the content of Computing.Net and its accuracy.
PLEASE READ THE FULL DISCLAIMER AND LEGAL TERMS BY CLICKING HERE

All content ©1996-2007 Computing.Net, LLC