I wrote a simple batch file that only writes an eventlog with message: SessionID = %SessionName%.
I want to run the script for users (which aren't connected to the domain) everytime they logon.
I don't want to restart the machine to run the script. (So I cannot just put the script in the "start folder".
I have some problems:
0. Is there a way to set that via c# code?
1. How do I assign this script to be every user logon script? I read many ways to do so but none worked for me (premission mainly).
2. Sometimes when I run the batch file locally and manually - the "SessionName" variable doesn't appear in the environment variables. but only sometimes. What could be the reason ?
3. Now I run rdp.exe via c# to open new sessions. I have also tried to run Psexec with -i flag (attached to a specific session) but SessionName was missing again... Any ideas?
4. Another solution I have thought of:
execute it remotely using Psexec --> cmd --->batch file (withut the cmd "in the middle" the SessionName doesn't appear).
so I have tried
c:\PsTools\psexec.exe \\<Server> -u test2 -p <Password> -i 2 cmd "c:\Users\test-2\Desktop\a"
or
c:\PsTools\psexec.exe \\<server> -u test2 -p <Password> -i 2 "cmd \"c:\Users\test-2\Desktop\a\""
all of these just open a terminal on the remote machine but don't execute the batch.
?
Bookmarks