# batch file nerds... need help. I'm a little rusty

**URL:** https://forums.speedlife.net/t/batch-file-nerds-need-help-im-a-little-rusty/27718
**Category:** NYSpeed Off Topic
**Created:** [April 16, 2007, 12:09pm UTC](https://forums.speedlife.net/t/batch-file-nerds-need-help-im-a-little-rusty/27718 "2007-04-16T12:09:38Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![Dr.Stevil](https://avatars.discourse-cdn.com/v4/letter/d/da6949/32.png) [@Dr.Stevil](https://forums.speedlife.net/u/Dr.Stevil)
#### Post date: [April 16, 2007, 12:09pm UTC](https://forums.speedlife.net/t/batch-file-nerds-need-help-im-a-little-rusty/27718/1 "2007-04-16T12:09:38Z")

</div>

ok, I havent done this since I was like 15 but need this done for work.

what I’m trying to do is create a batch file that’ll take a file, rename it to something else, then run an EXE, then once the EXE is closed, rename said file back to what it was originally.

what I have so far is

> @echo on  
> ren m:\batch est1.txt test2.txt  
> start C:\Program files\UGS\NX 3.0\UGII\ugraf.exe  
> ren m:\batch est2.txt test1.txt

it renames said files ok without any problems, but it doesnt want to run ugraf.exe. I remember back when I used to do this, windows at the time didn’t support long file names, so I’d have to use below instead for **Program Files**

> @echo on  
> ren m:\batch est1.txt test2.txt  
> start C:\Progra~1\UGS\NX 3.0\UGII\ugraf.exe  
> ren m:\batch est2.txt test1.txt

this didn’t seem to work either… keeps telling me that

“windows cannot find \*. Make sure you typed the name correctly, and then try again. To search for a file, click the start button, and then click search”

I’m 100% sure that this is where the exe is located. Am I missing something? Is it because of the **3.0** in the folder names?

also, This is going to have to change a file that’s in the c:\windows folder which none of our users have access to modify. I assume, under my admin account, I can just set the permissions for users to access this folder? or even better, can I just set the file to let users modify it?

---

<div class="post-metadata">

### Author: ![Zer0DazE](https://yyz2.discourse-cdn.com/flex034/user_avatar/forums.speedlife.net/zer0daze/32/7624_2.png) [@Zer0DazE](https://forums.speedlife.net/u/Zer0DazE)
#### Post date: [April 16, 2007, 12:16pm UTC](https://forums.speedlife.net/t/batch-file-nerds-need-help-im-a-little-rusty/27718/2 "2007-04-16T12:16:27Z")

</div>

you dont need to use “start”  
your machine is trying to run a program named “start”

---

<div class="post-metadata">

### Author: ![ILCisDEAD](https://avatars.discourse-cdn.com/v4/letter/i/a87d85/32.png) [@ILCisDEAD](https://forums.speedlife.net/u/ILCisDEAD)
#### Post date: [April 16, 2007, 12:17pm UTC](https://forums.speedlife.net/t/batch-file-nerds-need-help-im-a-little-rusty/27718/3 "2007-04-16T12:17:02Z")

</div>

are you copying exactly what the tab completion gives you?

---

<div class="post-metadata">

### Author: ![ILCisDEAD](https://avatars.discourse-cdn.com/v4/letter/i/a87d85/32.png) [@ILCisDEAD](https://forums.speedlife.net/u/ILCisDEAD)
#### Post date: [April 16, 2007, 12:18pm UTC](https://forums.speedlife.net/t/batch-file-nerds-need-help-im-a-little-rusty/27718/4 "2007-04-16T12:18:36Z")

</div>

[quote=“Zer0DazE,post:2,topic:27718"”]

you dont need to use “start”  
your machine is trying to run a program named “start”

[/quote]

you sure?

@echo off  
start /wait /b First.exe  
start /wait /b Second.exe  
start /wait /b Third.exe

just an example… I’m not good with batch at all… but it seems like its missing something

[http://www.ss64.com/nt/start.html](http://www.ss64.com/nt/start.html)

maybe thats helpfull…

**[An A-Z Index of Windows CMD commands - SS64.com](http://www.ss64.com/nt/)**

---

<div class="post-metadata">

### Author: ![Dr.Stevil](https://avatars.discourse-cdn.com/v4/letter/d/da6949/32.png) [@Dr.Stevil](https://forums.speedlife.net/u/Dr.Stevil)
#### Post date: [April 16, 2007, 12:22pm UTC](https://forums.speedlife.net/t/batch-file-nerds-need-help-im-a-little-rusty/27718/5 "2007-04-16T12:22:14Z")

</div>

[quote=“Zer0DazE,post:2,topic:27718"”]

you dont need to use “start”  
your machine is trying to run a program named “start”

[/quote]

that’s how I first had it, then upon a google search it was reccomended adding “start” (it just tells the computer that you want to start a windows executible). Either way, it gives me the same error

> are you copying exactly what the tab completion gives you?

no that was from the actual batch file I saved

here is what the actual screen reads

---

<div class="post-metadata">

### Author: ![Zer0DazE](https://yyz2.discourse-cdn.com/flex034/user_avatar/forums.speedlife.net/zer0daze/32/7624_2.png) [@Zer0DazE](https://forums.speedlife.net/u/Zer0DazE)
#### Post date: [April 16, 2007, 12:24pm UTC](https://forums.speedlife.net/t/batch-file-nerds-need-help-im-a-little-rusty/27718/6 "2007-04-16T12:24:33Z")

</div>

its because there is a space in the command line without a quote

and you are right, use start

---

<div class="post-metadata">

### Author: ![ILCisDEAD](https://avatars.discourse-cdn.com/v4/letter/i/a87d85/32.png) [@ILCisDEAD](https://forums.speedlife.net/u/ILCisDEAD)
#### Post date: [April 16, 2007, 12:25pm UTC](https://forums.speedlife.net/t/batch-file-nerds-need-help-im-a-little-rusty/27718/7 "2007-04-16T12:25:24Z")

</div>

yea its stopping at  
x the space is the problem it seems

try start “path”

or just running it right in the directory 🙂

---

<div class="post-metadata">

### Author: ![Dr.Stevil](https://avatars.discourse-cdn.com/v4/letter/d/da6949/32.png) [@Dr.Stevil](https://forums.speedlife.net/u/Dr.Stevil)
#### Post date: [April 16, 2007, 12:25pm UTC](https://forums.speedlife.net/t/batch-file-nerds-need-help-im-a-little-rusty/27718/8 "2007-04-16T12:25:43Z")

</div>

should I just use a “\*” or “?” for this instance? or some other kind of wildcard

---

<div class="post-metadata">

### Author: ![Dr.Stevil](https://avatars.discourse-cdn.com/v4/letter/d/da6949/32.png) [@Dr.Stevil](https://forums.speedlife.net/u/Dr.Stevil)
#### Post date: [April 16, 2007, 12:26pm UTC](https://forums.speedlife.net/t/batch-file-nerds-need-help-im-a-little-rusty/27718/9 "2007-04-16T12:26:14Z")

</div>

thanks for the help too guys, much appreciated 🍺

---

<div class="post-metadata">

### Author: ![ILCisDEAD](https://avatars.discourse-cdn.com/v4/letter/i/a87d85/32.png) [@ILCisDEAD](https://forums.speedlife.net/u/ILCisDEAD)
#### Post date: [April 16, 2007, 12:28pm UTC](https://forums.speedlife.net/t/batch-file-nerds-need-help-im-a-little-rusty/27718/10 "2007-04-16T12:28:33Z")

</div>

what would you need a wildcard for? are you trying to run everything?

“filepath” should be fine… in my inexperienced batch syntax opinion…

things like this … make me love perl soo much more

---

<div class="post-metadata">

### Author: ![Dr.Stevil](https://avatars.discourse-cdn.com/v4/letter/d/da6949/32.png) [@Dr.Stevil](https://forums.speedlife.net/u/Dr.Stevil)
#### Post date: [April 16, 2007, 12:34pm UTC](https://forums.speedlife.net/t/batch-file-nerds-need-help-im-a-little-rusty/27718/11 "2007-04-16T12:34:58Z")

</div>

I forgot how I used to do it, but I remember back when I used to have to setup the ol autoexec.bat there was a command to set filepaths into memory so you didn’t need to psysically NEED to be in that directory to launch the command.

I figure I could do that to the c:\progra~1\UGS folder and then just go “START Ugraf.exe”

anyone know what I’m talking about? lol

---

<div class="post-metadata">

### Author: ![JayS](https://yyz2.discourse-cdn.com/flex034/user_avatar/forums.speedlife.net/jays/32/15375_2.png) [@JayS](https://forums.speedlife.net/u/JayS)
#### Post date: [April 16, 2007, 12:35pm UTC](https://forums.speedlife.net/t/batch-file-nerds-need-help-im-a-little-rusty/27718/12 "2007-04-16T12:35:43Z")

</div>

Wrap C:\Program files\UGS\NX 3.0\UGII\ugraf.exe in quotes.

IE…  
  
_ren m:\batch est1.txt test2.txt  
start “C:\Program files\UGS\NX 3.0\UGII\ugraf.exe”  
ren m:\batch est2.txt test1.txt_

It will work. I do this all the time to syncshell the winzip command line program to make encrypted data backups. The only thing I’m not sure about is if your batch file will wait for ugraf.exe to complete execution before moving to the next line. You may have to add a pause in there.

---

<div class="post-metadata">

### Author: ![ILCisDEAD](https://avatars.discourse-cdn.com/v4/letter/i/a87d85/32.png) [@ILCisDEAD](https://forums.speedlife.net/u/ILCisDEAD)
#### Post date: [April 16, 2007, 12:36pm UTC](https://forums.speedlife.net/t/batch-file-nerds-need-help-im-a-little-rusty/27718/13 "2007-04-16T12:36:02Z")

</div>

we’ve told him to do this… and no response if it works or not

---

<div class="post-metadata">

### Author: ![Dr.Stevil](https://avatars.discourse-cdn.com/v4/letter/d/da6949/32.png) [@Dr.Stevil](https://forums.speedlife.net/u/Dr.Stevil)
#### Post date: [April 16, 2007, 12:39pm UTC](https://forums.speedlife.net/t/batch-file-nerds-need-help-im-a-little-rusty/27718/14 "2007-04-16T12:39:39Z")

</div>

oh, sorry bout that… didn’t even see it.

ok, tried that and it stopped giving me the error, but instead of launching the app, it’s just launching another instance of CMD.EXE

:\

---

<div class="post-metadata">

### Author: ![JayS](https://yyz2.discourse-cdn.com/flex034/user_avatar/forums.speedlife.net/jays/32/15375_2.png) [@JayS](https://forums.speedlife.net/u/JayS)
#### Post date: [April 16, 2007, 12:40pm UTC](https://forums.speedlife.net/t/batch-file-nerds-need-help-im-a-little-rusty/27718/15 "2007-04-16T12:40:46Z")

</div>

Remove the word start.

---

<div class="post-metadata">

### Author: ![Dr.Stevil](https://avatars.discourse-cdn.com/v4/letter/d/da6949/32.png) [@Dr.Stevil](https://forums.speedlife.net/u/Dr.Stevil)
#### Post date: [April 16, 2007, 12:42pm UTC](https://forums.speedlife.net/t/batch-file-nerds-need-help-im-a-little-rusty/27718/16 "2007-04-16T12:42:22Z")

</div>

[quote=“JayS,post:15,topic:27718"”]

Remove the word start.

[/quote]

perfect :tup: thanks again guys

edit: now to remember how to use wildcards and variables 😛 need this to be able to rename 2 different files based upon a users keystroke

wish me luck lol

---

<div class="post-metadata">

### Author: ![JayS](https://yyz2.discourse-cdn.com/flex034/user_avatar/forums.speedlife.net/jays/32/15375_2.png) [@JayS](https://forums.speedlife.net/u/JayS)
#### Post date: [April 16, 2007, 12:47pm UTC](https://forums.speedlife.net/t/batch-file-nerds-need-help-im-a-little-rusty/27718/17 "2007-04-16T12:47:20Z")

</div>

Heh… I just tried this, copying notepad.exe to c:\program files  
ote pad  
otep.exe:

_ren c:\batch est1.txt test2.txt  
“c:\program files  
ote pad  
otep.exe”  
ren c:\batch est2.txt test1.txt_

And sure enough, the batch file does pause until I close notepad. While notepad is open, the txt file is “test2.txt”. As soon as I close it the batch file renames it “test1.txt”.

---

<div class="post-metadata">

### Author: ![Dr.Stevil](https://avatars.discourse-cdn.com/v4/letter/d/da6949/32.png) [@Dr.Stevil](https://forums.speedlife.net/u/Dr.Stevil)
#### Post date: [April 16, 2007, 12:53pm UTC](https://forums.speedlife.net/t/batch-file-nerds-need-help-im-a-little-rusty/27718/18 "2007-04-16T12:53:32Z")

</div>

thats good to know… maybe I should have it launch an independant batch file opposed to just the one in case the batch is closed before the program is (so to prevent something goofy happening as the file I’m renaming is an INI in the windows folder depending on which version of said software the user is launching)

lol I’m having flashbacks to christmas of 95 when I got my first q-basic book 😃

---

<div class="post-metadata">

### Author: ![ILCisDEAD](https://avatars.discourse-cdn.com/v4/letter/i/a87d85/32.png) [@ILCisDEAD](https://forums.speedlife.net/u/ILCisDEAD)
#### Post date: [April 16, 2007, 1:39pm UTC](https://forums.speedlife.net/t/batch-file-nerds-need-help-im-a-little-rusty/27718/19 "2007-04-16T13:39:06Z")

</div>

lol i remember being one of those assholes making batch files to fuck with others…

---

<div class="post-metadata">

### Author: ![Dr.Stevil](https://avatars.discourse-cdn.com/v4/letter/d/da6949/32.png) [@Dr.Stevil](https://forums.speedlife.net/u/Dr.Stevil)
#### Post date: [April 16, 2007, 1:54pm UTC](https://forums.speedlife.net/t/batch-file-nerds-need-help-im-a-little-rusty/27718/20 "2007-04-16T13:54:04Z")

</div>

lol same… used to fuck with the librarians computers in school 😛

> REM CADRA SELECT MENU  
> @echo off
> 
> cls
> 
> ECHO CADRA v10.4.0/CADRA 2006 PLUS SELECT MENU  
> ECHO \*  
> ECHO \*  
> ECHO VERY IMPORTANT, PLEASE DO NOT CLOSE THIS WINDOW AT ANY TIME  
> ECHO \*  
> ECHO \*  
> ECHO \*
> 
> PAUSE  
> cls  
> echo Please Choose An Option  
> echo;  
> echo (1) Run CADRA v.10.0.4  
> echo (2) Run CADRA v2006 PLUS  
> echo;  
> set /p userinp=choose a number(1-2):  
> set userinp=%userinp:~0,1%  
> if “%userinp%”==“2” goto 20  
> if “%userinp%”==“1” goto 10  
> :10  
> ren m:\batch est1.txt test2.txt
> 
> “C:\Program files\UGS\NX 3.0\UGII\ugraf.exe”
> 
> ren m:\batch est2.txt test1.txt
> 
> goto end  
> :20  
> ren m:\batch\alt1.txt alt2.txt
> 
> “C:\Program files\UGS\NX 3.0\UGII\ugraf.exe”
> 
> ren m:\batch\alt2.txt alt1.txt  
> goto end  
> :end
> 
> exit

coming along nicely… supprised that the “choice” command no longer exists though

now that I have the template, just need to apply it to the real world and tweak it
