| View previous topic :: View next topic |
| Author |
Message |
neXt
Joined: 19 Mar 2007 Posts: 463
|
Posted: Fri Mar 07, 2008 6:42 am Post subject: START - problem, any1 knows batch scripting? |
|
|
i ran into a weird problem with a "bat" file that i'm making.
| Code: | | START "C:\documents and settings\user\somefile.exe" | is not working and i'm soooooooo confused, 'cause
| Code: | | START C:\"documents and settings\user\somefile.exe" | works just fine. I'm guessing that "colon" is the one that messes stuff up, tried some character escaping with no positive results.
How can i fix this? |
|
| Back to top |
|
 |
aCkRiTe
Joined: 21 Jul 2006 Posts: 502
|
Posted: Fri Mar 07, 2008 6:50 am Post subject: |
|
|
This should work:
| Code: |
START "" "C:\documents and settings\user\somefile.exe"
|
the first set of colons is for the title name of the window. _________________
HTH...
 |
|
| Back to top |
|
 |
ManaUser
Joined: 24 May 2007 Posts: 901
|
Posted: Fri Mar 07, 2008 7:02 am Post subject: |
|
|
I think the problem is that it expects the first thing in quotes to be the "title" parameter. I maybe thought that meant the command doesn't need quotes, but it does.
This seemed to work:
| Code: | | START "" "C:\documents and settings\user\somefile.exe" |
But I'm not sure if specifying a blank title might do any harm, it didn't seem to have any effect when I started notepad with it. |
|
| Back to top |
|
 |
neXt
Joined: 19 Mar 2007 Posts: 463
|
Posted: Fri Mar 07, 2008 3:55 pm Post subject: |
|
|
Thanks guys ! |
|
| Back to top |
|
 |
neXt
Joined: 19 Mar 2007 Posts: 463
|
Posted: Fri Mar 07, 2008 4:22 pm Post subject: |
|
|
How do i loop through files and launch my app. only after it's been detected?
This language is so confusing, here's what i have so far:
| Code: |
If Exist "C:\Documents and Settings\me\Desktop\scripts\Alias\Alias.ahk"
DEL "C:\Documents and Settings\me\Desktop\scripts\Alias\Alias.exe"
XCOPY "\\Cwidomain\Accounting\GENERAL\Scripts\Alias\Alias.exe" "C:\Documents and Settings\me\Desktop\scripts\Alias\"
FOR \R "C:\Documents and Settings\me\Desktop\scripts\Alias\" %%G IN (*.exe) DO
If Exist "C:\Documents and Settings\me\Desktop\scripts\Alias\Alias.ahk" EXIT FOR
START "" "C:\Documents and Settings\me\Desktop\scripts\Alias\Alias.ahk"
|
|
|
| Back to top |
|
 |
Fry
Joined: 01 Nov 2007 Posts: 610
|
Posted: Sat Mar 08, 2008 7:38 pm Post subject: |
|
|
i use Call instead of Start to run a program in batch
@neXt i dont think it is confusing. _________________ check out my site
www.eliteknifesquad.com |
|
| Back to top |
|
 |
m^2
Joined: 28 Feb 2008 Posts: 56 Location: Krk, PL
|
Posted: Sat Mar 08, 2008 7:52 pm Post subject: |
|
|
| Fry wrote: | i use Call instead of Start to run a program in batch
@neXt i dont think it is confusing. |
Why? As far as I know "call myprog.exe" is not different from "myprog.exe".
Am I wrong?
Start is different because it doesn't wait for the program to exit. _________________ Waiting for Windows 8... |
|
| Back to top |
|
 |
neXt
Joined: 19 Mar 2007 Posts: 463
|
Posted: Sat Mar 08, 2008 11:56 pm Post subject: |
|
|
Fry, so if you know it, can you help me? i want it to run my app only after copying is fully complete. For now i settled with making it sleep for 5 seconds, but this is a weak solution since if a PC will lag and take longer than 5 secs to copy then update will be unsuccessful.
P.S from online references i understood that call is used to call another bat from you script, kind of like in VBA when you call another module. |
|
| Back to top |
|
 |
aCkRiTe
Joined: 21 Jul 2006 Posts: 502
|
Posted: Sun Mar 09, 2008 12:50 am Post subject: |
|
|
Im not a 100% sure, but doesnt the copy command wait for the file to be copied before moving to the next line in the script. You can always check the errorlevel to ensure there were no problems. The errorlevel should return 0 if copied correctly.
| Code: |
:Copy
copy "\\Cwidomain\Accounting\GENERAL\Scripts\Alias\Alias.exe" "C:\Documents and Settings\me\Desktop\scripts\Alias\"
If %ErrorLevel% NEQ 0 Goto Copy
|
if the copy command doesnt wait for the file to be copied or you having issues with it, you can always create a second batch file with just the copy command in it and call it using the start /wait commad. This with wait for the second batch to finish before moving on in your main batch file. _________________
HTH...
 |
|
| Back to top |
|
 |
neXt
Joined: 19 Mar 2007 Posts: 463
|
Posted: Sun Mar 09, 2008 1:27 am Post subject: |
|
|
So copy will wait until a file is fully copied before moving on? I'll test it out on Monday, i didn't know that.
I should be good now , thanks for this tip. |
|
| Back to top |
|
 |
aCkRiTe
Joined: 21 Jul 2006 Posts: 502
|
Posted: Sun Mar 09, 2008 1:30 am Post subject: |
|
|
yes, I pretty sure both copy and xcopy wait for the file to be copied. I tested copying a large file with a pause in the next line of the batch file I had the destination folder open and it seemed to wait for the file to be there before I saw the pause command take effect. Anyways, hope this helps... _________________
HTH...
 |
|
| Back to top |
|
 |
neXt
Joined: 19 Mar 2007 Posts: 463
|
Posted: Sun Mar 09, 2008 3:19 am Post subject: |
|
|
It does help , thanks a lot! |
|
| Back to top |
|
 |
|