Search found 126 matches
- 02 Aug 2011 08:02
- Forum: DOS Batch Forum
- Topic: Batch file to run cmds only if user is NOT an administrator
- Replies: 5
- Views: 5485
Re: Batch file to run cmds only if user is NOT an administr
You can use this in XP and Windows 7... IF NOT "%USERNAME%"=="administrator" ( Do some commands for users ) ELSE ( Do some other commands Exit /b ) OR IF /I "%USERNAME%" NEQ "administrator" ( Do your commands for normal users ) ELSE ( Do other commands ) Actua...
- 01 Aug 2011 14:38
- Forum: DOS Batch Forum
- Topic: IF Statement Syntax
- Replies: 24
- Views: 16284
Re: IF Statement Syntax
That's awsome! Thanks Dave.
I guess I assumed at some point that since DOS would parse && and || that it would parse them anywhere, much like many of the other little tricks that work in multiple places.
I guess I assumed at some point that since DOS would parse && and || that it would parse them anywhere, much like many of the other little tricks that work in multiple places.
- 01 Aug 2011 13:18
- Forum: DOS Batch Forum
- Topic: IF Statement Syntax
- Replies: 24
- Views: 16284
Re: IF Statement Syntax
Where did you find this syntax?
Code: Select all
set "test=/BH/TD/RB/RC/AB/"
if "!test:/%Check%/=!" neq "!test!" (
<Some Commands if found a match>
) else (
<Other Commands>
)
- 01 Aug 2011 12:19
- Forum: DOS Batch Forum
- Topic: IF Statement Syntax
- Replies: 24
- Views: 16284
IF Statement Syntax
I could have sworn that this syntax worked, but maybe I'm losing my mind... IF "!Check!"=="BH" || IF "!Check!"=="TD" || IF "!Check!"=="RB" || IF "!Check!"=="RC" || IF "!Check!"=="AB" ( Some Commands )...
- 29 Jul 2011 11:26
- Forum: DOS Batch Forum
- Topic: Question on Not So basic macros
- Replies: 18
- Views: 13711
Re: Question on Not So basic macros
Ok I was looking at it wrong then... Here's what I get: Var2=^"eol^=^ ^ delims^=^" The blank line under delims is put there before I get the next pompt and not part of the definition. I also missed that quote. I'm going to guess that the ^ is actually escaping the quote in the definition t...
- 29 Jul 2011 11:12
- Forum: DOS Batch Forum
- Topic: Variable doesn't get overwritten
- Replies: 4
- Views: 4266
Re: Variable doesn't get overwritten
Welcome to the forums! Without seeing more of your script, it will be hard to tell for sure, but I think you're doing 1 of two things: 1. You're declaring the %RND% variable before doing any SetLocal and expecting that this is now a global variable and all mods to it would then also be global. The p...
- 26 Jul 2011 07:37
- Forum: DOS Batch Forum
- Topic: Question on Not So basic macros
- Replies: 18
- Views: 13711
Re: Question on Not So basic macros
Thanks Dave, that helped. So the \n is not functionally necessary, but since it's difficult to trouble-shoot macros without using the SET command, it makes them easier to read and find errors etc... And eol and delims end up just being = %LF% ? When I use the example you provided, it looks like they...
- 25 Jul 2011 17:14
- Forum: DOS Batch Forum
- Topic: Question on Not So basic macros
- Replies: 18
- Views: 13711
Re: Question on Not So basic macros
For purposes of understanding, all that CMD stuff in my macro can be replaced by passing a csv file through the FOR loop with the TYPE command like: FOR .... IN ('TYPE mycsvfile.csv') DO ... And in fact, that's all the output of the CSVFix command is doing is outputing line by line a CSV file, no di...
- 25 Jul 2011 11:54
- Forum: DOS Batch Forum
- Topic: Question on Not So basic macros
- Replies: 18
- Views: 13711
Re: Question on Not So basic macros
I figured it out. I needed to double-up the ^ before the parenthesis. The rest of the ^ were not eaten up by the set command, but those were.
I think I have a handle on this macro thing now
I still don't fully understand the %\n% but I know where to look for the explanation of it.
I think I have a handle on this macro thing now
I still don't fully understand the %\n% but I know where to look for the explanation of it.
- 25 Jul 2011 08:24
- Forum: DOS Batch Forum
- Topic: Question on Not So basic macros
- Replies: 18
- Views: 13711
Re: Question on not so basic macros
Ok, so my Batch just reached 250 lines and I'm only about halfway through it. It takes roughly about 10 minutes to run at this point and I though I thought I might be able to pick up some speed here, but I'm getting an error. SET LF=^ ::Above 2 blank lines are required - do not remove SET ^"\n=...
- 22 Jul 2011 17:11
- Forum: DOS Batch Forum
- Topic: running batch file without extension
- Replies: 3
- Views: 7414
Re: running batch file without extension
Have you tried it?
If you have multiple files with the same name you could run into problems but yes you can run a command or executable without the .exe or .bat, etc...
If you have multiple files with the same name you could run into problems but yes you can run a command or executable without the .exe or .bat, etc...
- 22 Jul 2011 07:49
- Forum: DOS Batch Forum
- Topic: VER for the File Version number of my chosen *.EXE
- Replies: 12
- Views: 11640
Re: VER for the File Version number of my chosen *.EXE
You can use Filever.exe Alan...
It's not an internal command, but it is native windows, but you do have to download it or extract it because by default it's not there I don't think...
Here's a link: http://support.microsoft.com/kb/913111
It's not an internal command, but it is native windows, but you do have to download it or extract it because by default it's not there I don't think...
Here's a link: http://support.microsoft.com/kb/913111
- 22 Jul 2011 07:44
- Forum: DOS Batch Forum
- Topic: How to run a ms dos batch file?
- Replies: 1
- Views: 2754
Re: How to run a ms dos batch file?
Just a few things...
Java is not a batch file.
If I were you I wouldn't just double-click something because my friends said so. Then again, I know who my friends are so maybe it's different in your case.
Java is not a batch file.
If I were you I wouldn't just double-click something because my friends said so. Then again, I know who my friends are so maybe it's different in your case.
- 22 Jul 2011 07:29
- Forum: DOS Batch Forum
- Topic: Quick question
- Replies: 6
- Views: 6123
Re: Quick question
you need to disable DELIMS and EOL (there are a few recent posts that show how to do this) I use my ForEntireLine macro. So THAT is what that's for! You would think that with a name like "ForEntireLine" it would be obvious but sometimes you have to be beaten over the head with obvious bef...
- 21 Jul 2011 15:51
- Forum: DOS Batch Forum
- Topic: Using :: syntax for comment in a FOR loop can break things
- Replies: 10
- Views: 8908
Re: Using :: syntax for comment in a FOR loop can break thin
One of the rules of :: inside brackets is that it always has to be followed by a valid command. Nevermind, I know why it works... a label is not valid as the last command in a block which is specified by ( and ). So as long as you have something even if it is echo.>null it's still a valid command. ...