Skip to content
View in the app

A better way to browse. Learn more.

MSFN

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Is this reg string unique to each install?

Featured Replies


NM :D

However, that script produces "SID not found" fo rme too, and that's the only reason I can thik of...

Edited by nakira

@ nakira

I think you may be correct, if we have some more confirmations on this, I'll adjust the code to suit…

Edited by Yzöwl

Fine this way

@echo off&setlocal enableextensions enabledelayedexpansion
for /f "tokens=*" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList" /s^|findstr "S-1-5-"') do (
for /f "tokens=1,3 delims= " %%b in ('reg query "%%~a" /v "ProfileImagePath"') do (
 if errorlevel 0 (
  set userkey1="%%~c"&set userkey2="%%SystemDrive%%\%userprofile:*\=%"
  if !userkey1! equ !userkey2! set UserSID=%%a&goto next
 )
)
)
:next
if not defined UserSID echo/ SID not found&&endlocal&goto :eof
set UserKey=HKU\%UserSID:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\=%
echo/ Your Users Registry Key %UserKey%&&echo/ is set as %%UserKey%%
pause&endlocal&goto :eof

I may be wrong here but in this line...

if errorlevel 0 if "%%~c" equ "%UserProfile%" set UserSID=%%a

The two STRINGS are not equal (for me)

"%%~c" expands to "%SystemDrive%\Documents and Settings\Nakira"

"%UserProfile%" expands to "C:\Documents and Settings\Nakira"

What about just changing the command
  • if errorlevel 0 if "%%~c" equ "%UserProfile%" set UserSID=%%a

to

  • if errorlevel 0 if "%%~fc" equ "%UserProfile%" set UserSID=%%a

Edited by Yzöwl

No go, that ends up like this

"C:\Documents and Settings\Nakira\Desktop\Settings\Nakira" (run from desktop)

or

"C:\Settings\Nakira" (run from C:\)

Last quickfix, before looking at a rewrite!

@echo off&setlocal enableextensions
for /f "tokens=*" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList" /s^|findstr "S-1-5-"') do (
for /f "tokens=1,3 delims= " %%b in ('reg query "%%~a" /v "ProfileImagePath"') do (
if errorlevel 0 (
echo/%%~c|find "%userprofile%">nul
if errorlevel 0 set UserSID=%%a
)
)
)
if not defined UserSID echo/ SID not found&&endlocal&goto :eof
set UserKey=HKU\%UserSID:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\=%
echo/ Your Users Registry Key %UserKey%&&echo/ is set as %%UserKey%%
pause&endlocal&goto :eof

Yzöwl that last one worked for me perfectly

But I only have 1 user on this PC

Edited by maxXPsoft

At last… :)

So all you need to do is replace the line

  • echo/ Your Users Registry Key %UserKey%&&echo/ is set as %%UserKey%%

with your registry related code, using the %UserKey% variable instead of HKCU, (HKEY_CURRENT_USER).

Example

REG ADD %UserKey%\SOFTWARE\Synaptics\SynTP\TouchPadHEXBTNPS2 /v Gestures /t REG_DWORD /d 2 /f

Note - Please make sure after pasting the code into your text editor that delims=<tab>" not delims=<space(s)>"

<Edit>

Special thanks to nakira for highlighting the cause of the problem.

</Edit>

Edited by Yzöwl

  • Author

You got it dude :hello:

C:\Documents and Settings\MYUSERNAME\Desktop>test.cmd
Your Users Registry Key HKU\S-1-5-21-1085031214-1682526488-1343024091-1003
is set as %UserKey%
Click any key to continue...

Edited by BoardBabe

  • 1 year later...
You got it dude :hello:

C:\Documents and Settings\MYUSERNAME\Desktop>test.cmd
Your Users Registry Key HKU\S-1-5-21-1085031214-1682526488-1343024091-1003
is set as %UserKey%
Click any key to continue...

I would like to make a point that this code will NOT work in the following senario:

User 1 logs on and runs script, getting s-1-blah-1003

User 1 chooses "switch user"

User 2 logs on and runs script.

Now, the code will still display the SID from the first user that logged on, user 1. s-1-blah-1003

How do we get this code to work in this situation?

Edited by drumminforev

@echo off&setlocal enableextensions
for /f "skip=1" %%a in ('wmic useraccount where name^="%username%" get SID') do set UserKey=HKU\%%a
echo * %%UserKey%% Value: %Userkey%
endlocal&pause

@echo off&setlocal enableextensions
for /f "skip=1" %%a in ('wmic useraccount where name^="%username%" get SID') do set UserKey=HKU\%%a
echo * %%UserKey%% Value: %Userkey%
endlocal&pause

My never ending thanks go to you!

Amazing!

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.