Bat file for logon script
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"
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.
Re: Bat file for logon script
Actually it depends on what server you are using still here you have the steps to create a login script.
Last edited by ZeDaX : 10-05-2010 at 12:45 PM.
|Tags: bat file, logon script, script|
|Thread Tools||Search this Thread|
|Similar Threads for: "Bat file for logon script"|
|Thread||Thread Starter||Forum||Replies||Last Post|
|Dumping logon name and logon script values to a text file - blank logon script field||Phil McNeill||Windows Server Help||3||17-08-2010 10:06 PM|
|Run logon script||Sandy22||Operating Systems||6||08-06-2010 11:16 AM|
|Logon Script Does Not Work||c54618||Operating Systems||1||01-05-2008 09:40 AM|
|domain logon script does not run||Onetoomany||Windows Server Help||4||11-02-2008 05:37 AM|
|logon script help||HandelMan||Small Business Server||1||31-01-2008 03:26 AM|