BATCH script problems...

This topic is 4021 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

Hoi! I am currently running a couple of batch scripts from my application. I would rather be using BASH but as far as I can tell there is no way to share a windows directory and then map it as a network drive from BASH. If I am wrong, PLEASE let me know!!! I am using 'net share' and 'net use' and as far as I can tell they do not report an error level on failure, but I need some way to figure out if they failed or not. Does anybody know how to do this in DOS Batch? I have considered grep'ing the output for certain strings but this seems like a fairly painstaking way to proceed. Any help with this would be greatly appreciated. Regards, Mark

Share on other sites
To catch the return code given by net.exe, try:

@echo offnet useecho %ERRORLEVEL%

When I do "net use", it gives 0.
When I do "net use X: \\skjdfdshfdshfdsf\sdjfds", it gives 2 (I assume this means "error!").

Share on other sites
taby,

Thanks, my original test was flawed, you are right when you say that net does create an error level.

Fortunately in the meantime I found a way around this!

Regards,

Mark

Share on other sites
I strongly recommend Windows PowerShell if you need to do this sort of thing frequently. It's very powerful, and ties in to the .NET framework to give you a massive class library to work with. [smile]

Share on other sites

What character is the wildcard from linux on the windows-console?

e.g. '> del *' -> "There's no such file, idiot!"

Share on other sites
Quote:
 Original post by hydrooWhat character is the wildcard from linux on the windows-console?
del * deletes all files in a directory. del * /q skips the prompt. As with most commands, del /? or help del displays further information.

(At least, del * deletes all the files under Vista). Some commands might require you to use *.* instead of *

Share on other sites
And is there no general wildcard? I mean is there no "sign" which tells the commandline to replace this with all matching files?

I want to do commands like "> myprogram *" and this should trigger the programm like "> myprogram file1 file2 file3 ..."

Share on other sites
... welcome to DOS :) It's nasty like that. For some bizarre reason, for example, you have to use this 'call' command to run one batch script from another, even though batch scripts are executable, and "normal" executables are fine... if you try to treat the other script like a .exe, then it will start, but Weird Things(TM) happen.

1. 1
Rutin
21
2. 2
3. 3
JoeJ
18
4. 4
5. 5

• 13
• 38
• 23
• 13
• 13
• Forum Statistics

• Total Topics
631715
• Total Posts
3001864
×