takeFirstStringContaining

Antworten
bobzbobz
Beiträge: 169
Registriert: 30 Nov 2012, 10:41
Wohnort: Denmark

takeFirstStringContaining

Beitrag von bobzbobz »

Hi

I am trying to make a package, which deletes Windows 7 temporary profiles in the registry.

I use this command to get the the users SID:

Code: Alles auswählen

Set $SIDcmd$ = getOutStreamFromSection ('DosInAnIcon_getuser')
Set $SID$ = takeFirstStringContaining($SIDcmd$,"S-")

[DosInAnIcon_getuser]
wmic useraccount where name='$UserProfileName$' get sid
This returns something like this:

Code: Alles auswählen

S-1-5-21-299502267-1647877149-1417001333-39507
Afterwards I want to delete this string in the registry:

Code: Alles auswählen

[Registry_install]
[HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\$SID$.bak]
The problem is that there is two white-spaces appended to the SID, like this:

Code: Alles auswählen

S-1-5-21-299502267-1647877149-1417001333-39507  .bak
Is there some way to get the string without the white spaces?

Regards
bobzbobz
Beiträge: 169
Registriert: 30 Nov 2012, 10:41
Wohnort: Denmark

Re: takeFirstStringContaining

Beitrag von bobzbobz »

Hello again

I just figured it out myself ;-)

Like this:

Code: Alles auswählen

Set $SID$ = trim(takeFirstStringContaining($SIDcmd$,"S-"))
Antworten