Hi,
I have a logon script to monitor all the logins. I have 2 things that i couldn't get to work properly.
Here's my script:
echo %date%,%time%,%computername%,%username%,%sessionname%,%logonserver% >> \\domain\Logon\LOGON.LOG
REG QUERY "HKEY_CURRENT_USER\Volatile Environment\ViewClient_Machine_Name">> \\domain\Logon\LOGON.LOG
1: The first part works OK, but sometimes it will randomly erase the file content and start all over again.
2: Second part; I'm trying to get a key from registry to get the inventory names of the terminals (VDI). Then again, it works alright, but i'm getting too much info out of it. I would like to get only the TRMxxxxx part and not what comes before it.
! REG.EXE VERSION 3.0
HKEY_CURRENT_USER\Volatile Environment
ViewClient_Machine_Name REG_SZ TRM12345
Thank you
Logon script
Moderator: DosItHelp
Re: Logon script
frederixx wrote:Here's my script:
echo %date%,%time%,%computername%,%username%,%sessionname%,%logonserver% >> \\domain\Logon\LOGON.LOG
REG QUERY "HKEY_CURRENT_USER\Volatile Environment\ViewClient_Machine_Name">> \\domain\Logon\LOGON.LOG
1: The first part works OK, but sometimes it will randomly erase the file content and start all over again.
Nothing in the batch file above will do that.
2: Second part; I'm trying to get a key from registry to get the inventory names of the terminals (VDI). Then again, it works alright, but i'm getting too much info out of it. I would like to get only the TRMxxxxx part and not what comes before it.
! REG.EXE VERSION 3.0
HKEY_CURRENT_USER\Volatile Environment
ViewClient_Machine_Name REG_SZ TRM12345
Use a for /f loop and tokens=3 along with find.exe to filter on the REG_SZ line, to echo the value.
Re: Logon script
foxidrive wrote:frederixx wrote:Here's my script:
echo %date%,%time%,%computername%,%username%,%sessionname%,%logonserver% >> \\domain\Logon\LOGON.LOG
REG QUERY "HKEY_CURRENT_USER\Volatile Environment\ViewClient_Machine_Name">> \\domain\Logon\LOGON.LOG
1: The first part works OK, but sometimes it will randomly erase the file content and start all over again.
Nothing in the batch file above will do that.
2: Second part; I'm trying to get a key from registry to get the inventory names of the terminals (VDI). Then again, it works alright, but i'm getting too much info out of it. I would like to get only the TRMxxxxx part and not what comes before it.
! REG.EXE VERSION 3.0
HKEY_CURRENT_USER\Volatile Environment
ViewClient_Machine_Name REG_SZ TRM12345
Use a for /f loop and tokens=3 along with find.exe to filter on the REG_SZ line, to echo the value.
If i get this correctly, i can only get rid of the last line? I'd also like to remove the first 2 lines from my logon.log:
! REG.EXE VERSION 3.0
HKEY_CURRENT_USER\Volatile Environment
Thank you
Re: Logon script
Do you know how find.exe works? Or findstr.exe?
Re: Logon script
foxidrive wrote:Do you know how find.exe works? Or findstr.exe?
No.
But from what i understand, it will filter my log file afterwards and won't prevent all the lines to show up in it.
Thanks