?
Solved

How to make A DOS .bat file work in Windows 7, I wrote a little batch file and it won't run

Posted on 2011-10-06
10
Medium Priority
?
483 Views
Last Modified: 2012-05-12
Here is the batch file I am not sure what I am doing wrong:

cd\

copy  C:\TEMP\Tech Tools\Software, Tools and Utilities\Disable AdobeFlash Updates\mms.cfg  c:\windows\system32\macromed\flash

Pause

C:\TEMP\Tech_Tools\Software, Tools and Utilities\Disable AdobeFlash Updates\disable java AutoUpdateChecking.reg

Pause

C:\TEMP\Tech_Tools\Software, Tools and Utilities\Disable AdobeFlash Updates\disable java update.reg

Pause

C:\TEMP\Tech_Tools\Software, Tools and Utilities\Disable Adobe Reader AutoUpdate.reg

Pause

C:\TEMP\Tech_Tools\Software, Tools and Utilities\Disable Adobe Reader UpdateUI.reg

Pause

"C:\TEMP\Tech_Tools\Software, Tools and Utilities\ccmsetup.exe

EXIT
0
Comment
Question by:boshenska
9 Comments
 
LVL 97

Accepted Solution

by:
Lee W, MVP earned 400 total points
ID: 36925624
You must quote the paths.  Otherwise, it looks like the command is "c:\temp\Tech_Tools\Software," and the parameters for that command are, for example, Tools and Utilities\Disable AdobeFlash Updates\disable java AutoUpdateChecking.reg
cd\

copy  "C:\TEMP\Tech Tools\Software, Tools and Utilities\Disable AdobeFlash Updates\mms.cfg"  "c:\windows\system32\macromed\flash"

Pause

"C:\TEMP\Tech_Tools\Software, Tools and Utilities\Disable AdobeFlash Updates\disable java AutoUpdateChecking.reg"

Pause

"C:\TEMP\Tech_Tools\Software, Tools and Utilities\Disable AdobeFlash Updates\disable java update.reg"

Pause

"C:\TEMP\Tech_Tools\Software, Tools and Utilities\Disable Adobe Reader AutoUpdate.reg"

Pause

"C:\TEMP\Tech_Tools\Software, Tools and Utilities\Disable Adobe Reader UpdateUI.reg"

Pause

"C:\TEMP\Tech_Tools\Software, Tools and Utilities\ccmsetup.exe"

EXIT

Open in new window

0
 
LVL 43

Assisted Solution

by:Steve Knight
Steve Knight earned 800 total points
ID: 36925656
also being win7 you may need to "run as administrator" as otherwise it will only run as your user token.
0
 
LVL 97

Expert Comment

by:Lee W, MVP
ID: 36925851
and the path quoting is required in ALL versions of Windows, not just Win7.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 59

Assisted Solution

by:Bill Prew
Bill Prew earned 400 total points
ID: 36926575
It can also be useful to use environment variables in the BAT script to save typing and reduce typos, as in:

setlocal
cd\
set ToolsDir=C:\TEMP\Tech Tools\Software, Tools and Utilities
copy "%ToolsDir%\Disable AdobeFlash Updates\mms.cfg" "c:\windows\system32\macromed\flash"
Pause
"%ToolsDir%\Disable AdobeFlash Updates\disable java AutoUpdateChecking.reg"
Pause
"%ToolsDir%\Disable AdobeFlash Updates\disable java update.reg"
Pause
"%ToolsDir%\Disable Adobe Reader AutoUpdate.reg"
Pause
"%ToolsDir%\Disable Adobe Reader UpdateUI.reg"
Pause
"%ToolsDir%\ccmsetup.exe"
EXIT

Open in new window

~bp
0
 
LVL 43

Assisted Solution

by:Steve Knight
Steve Knight earned 800 total points
ID: 36926655
Also surely each is prompting you for an answer "Y" to import?

have you considered using

regedit /s yourregfile.reg

@echo off
set thepath=C:\TEMP\Tech Tools\Software, Tools and Utilities
copy  "%thepath%\Disable AdobeFlash Updates\mms.cfg"  "%systemroot%\system32\macromed\flash"
Pause
regedit /s "%thepath%\Disable AdobeFlash Updates\disable java AutoUpdateChecking.reg"
Pause
regedit /s "%thepath%\Disable AdobeFlash Updates\disable java update.reg
regedit /s "%thepath%\Disable Adobe Reader AutoUpdate.reg
regedit /s "%thepath%\Disable Adobe Reader UpdateUI.reg
Pause
START "" "%thepath%\ccmsetup.exe"
EXIT
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 36926660
Sorry Bill, crossed posts there.  Similar idea but thought best add the regedit /s to silence the Y/N
0
 
LVL 39

Assisted Solution

by:BillDL
BillDL earned 400 total points
ID: 36938624
Hi boshenka

Why don't you just create one *.REG file containing all your "disable" lines, eg. "Disable_Flash_AdobeReader_Java_Updates.reg" and import that in one go?

I know it's probably just for convenience that you have *.reg files relating to Java and Adobe Flash/Acrobat Reader in one folder named "Disable AdobeFlash Updates", but I would suggest either useing separate sub-folders with appropriate names or else one folder and have useful names for the *.REG files.

For any folders I create that contain "Tools" I never use spaces, and instead use underscores.  Obviously double-quoting takes care of the spaces, but when testing batch files it's too easy to accidentally leave off a quote and mess something up.  I wouldn't choose "C:\TEMP" as a place to store utility programs and batch files either.  Of course you are maybe experimenting with a self-extracting package that unpacks then runs the batch file.  If that is the case, then it would probably be better to specify the logged on user's "Temp" file using the %temp% variable or the "All Users" temp folder.

It's down to all personal choice, but I would normally use folder and file names like this, because I know what "Softw", "Utils", "Upd", "AcroRd", etc all mean and don't feel the need to spell it all out in full with commas and so on:
Tech_Tools\Softw-Tools-Utils\Disable_Auto_Update\Flash_Upd_Off.reg
Tech_Tools\Softw-Tools-Utils\Disable_Auto_Update\AcroRd_Upd_Off.reg
Tech_Tools\Softw-Tools-Utils\Disable_Auto_Update\Java_Upd_Off.reg

Lengthy paths are a nuisance in batch files, and even with Bill Prews good suggestion of using Variables, you still have quite long lines.
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 36938808
a good point Bill.  I assumed he wanted them separate because they werent always needed etc.

could also use the reg.exe command of course if only, say ione or teo reg key/values need amending in them.

Steve
0
 
LVL 59

Expert Comment

by:LeeTutor
ID: 37089781
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
Unable to change the program that handles the scan event from a network attached Canon/Brother printer/scanner. This means you'll always have to choose which program handles this action, e.g. ControlCenter4 (in the case of a Brother).
This Micro Tutorial will teach you how to change your appearance and customize your Windows 7 interface to your unique preference. This will be demonstrated using Windows 7 operating system.
This Micro Tutorial will go in depth within Systems and Security in Windows 7 and will go into detail regarding Action Center, Windows Firewall, System, etc. This will be demonstrated using Windows 7 operating system.
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question