Score:0

How can I remove the first character of a variable from For and Tokens in a batch script?

cx flag

With a batch script to set variable from For and Tokens and remove the first char:

for /f "tokens=1,2,3,4,5,6,7,8" %A in (
 'net user %username% /domain ^| 
 find "Global Group memberships"' 
) 
do set groupname=%D:~1%

The groupname is like *Groupname and I need to delete the * char.

I check the variable using echo %groupname% the output is *Groupname:~1%

How can I get the desired result?

my flag
Can you please explain what it is you are trying to do?
my flag
I strongly recommend you use Powershell for this. For a couple reasons - 1) The net user command returns truncated group names and 2) powershell provides so much more capability with variable and string handling. 3) you are investing in a future proofed skill.
my flag
If you can load the AD module try this: `get-aduser $env:username -Properties memberof |select -expandproperty memberof|get-adgroup|select name`
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.