Search found 177 matches
- 2023-Aug-16, 4:54 pm
- Forum: Windows CMD Shell
- Topic: How to remove trailing backslash from %*
- Replies: 7
- Views: 10735
Re: How to remove trailing backslash from %*
The IF command can seem flaky if any spaces exist in the comparison strings. for example these 3 commands all seem to work OK IF '~a'=='~ a' Echo OK IF [~a]==[~ a] Echo OK IF "~a"=="~ a" Echo OK But if you reverse the logic to see if they are not equal IF '~a' NEQ '~ a' Echo OK I...
- 2023-Aug-14, 12:21 am
- Forum: Windows CMD Shell
- Topic: How to remove trailing backslash from %*
- Replies: 7
- Views: 10735
Re: How to remove trailing backslash from %*
From an answer on superuser.com I got this, which removes trailing backslashes from a variable: IF %datapath:~-1%==\ SET datapath=%datapath:~0,-1% Whatever I try, I cannot get it work with `%*` instead of `%datapath%`. Is there any way I can do this? Alternatively, I believe adding a trailing dot a...
- 2023-Aug-03, 5:40 pm
- Forum: Windows CMD Shell
- Topic: For /F - Tokens has me puzzled
- Replies: 6
- Views: 10273
Re: For /F - Tokens has me puzzled
Nice, may I suggest a few additions / changes? Thanks I'd never really considered listing the tokens in descending order. A slightly modified version of your example @echo off for /f "tokens=3,2,1,*" %%A in ("alpha beta gamma delta epsilon") do echo A:%%A B:%%B C:%%C D:%%D Outpu...
- 2023-Aug-03, 9:33 am
- Forum: Windows CMD Shell
- Topic: For /F - Tokens has me puzzled
- Replies: 6
- Views: 10273
Re: For /F - Tokens has me puzzled
From the for/f page: tokens=* will cause all items on each line to be processed. tokens=3* will process the third token and the 4th + all subsequent items, this can also be written as tokens=3,* Each token specified will cause a corresponding parameter letter to be allocated. The letters used for t...
- 2023-Aug-02, 5:00 pm
- Forum: Windows CMD Shell
- Topic: How to get user details out of Active Directory?
- Replies: 2
- Views: 9286
Re: How to get user details out of Active Directory?
If you don't want to install RSAT, then I would use VBScript, heres a sample script you can modify to return other properties:
Search
https://ss64.com/vb/syntax-ad.html
for current user
https://ss64.com/vb/syntax-userinfo.html
LDAP properties
https://ss64.com/ps/syntax-ldap.html
Search
https://ss64.com/vb/syntax-ad.html
for current user
https://ss64.com/vb/syntax-userinfo.html
LDAP properties
https://ss64.com/ps/syntax-ldap.html
- 2023-Jul-28, 8:54 pm
- Forum: Windows CMD Shell
- Topic: Output of %TIME% and Time/ T is region dependent
- Replies: 2
- Views: 10218
Output of %TIME% and Time/ T is region dependent
Over on the TIME page I have documented the output of TIME for a few regions, those were correct in 2018 but I am getting some reports that this output has changed for some regions in recentish builds of Windows 10 and 11. It any of you have TIME output which differ do post them here and I'll update...
- 2023-Jul-27, 11:43 am
- Forum: Windows CMD Shell
- Topic: Does "endlocal" close all instances of "setlocal"?
- Replies: 6
- Views: 10485
Re: Does "endlocal" close all instances of "setlocal"?
I'm just curious: How many of you use setlocal by itself and not paired with enabledelayedexpansion, or enableextensions? I start every script with @echo off setlocal Just as a matter of habit, even for scripts which don't (yet) contain any variables. If you run a script from a CMD session and it s...
- 2023-Jul-26, 6:09 pm
- Forum: Windows CMD Shell
- Topic: Does "endlocal" close all instances of "setlocal"?
- Replies: 6
- Views: 10485
Re: Does "endlocal" close all instances of "setlocal"?
So the answer is endlocal does not close all instances of setlocal . endlocal closes the most recent and non-ended setlocal. Yes and it couldn't be any other way, it restores the whole environment including any values which you had overwritten: @Echo off setlocal set _demo=start set _demo setlocal ...
- 2023-Jul-21, 12:24 pm
- Forum: Windows CMD Shell
- Topic: How to enter a NULL character?
- Replies: 1
- Views: 8753
- 2023-Jul-02, 1:17 pm
- Forum: Meta: Site Feedback / Forum Q&A
- Topic: wscript.Shell no xref to ExpandEnvironmentStrings
- Replies: 1
- Views: 75852
Re: wscript.Shell no xref to ExpandEnvironmentStrings
Thanks, have added that one now along with BrowseForFolder.