Go Back   TechArena Community > Software > Windows Software
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Thread Tools Search this Thread
Old 06-05-2010
Join Date: May 2010
Posts: 3
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.
Reply With Quote
Old 10-05-2010
Join Date: Mar 2009
Posts: 1,585
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.
  • Navigate to the folder where scripts are held on primary domain controller.
  • As you can only have one login script edit the existing text file.
  • Add the lines of instructions and then save it as a batch file.
  • Assign the script to the computers that need to run it. This is usually done by means of the user profile of the person who normally logs in to that workstation.

Last edited by ZeDaX : 10-05-2010 at 11:45 AM.
Reply With Quote

  TechArena Community > Software > Windows Software
Tags: , ,

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 09:06 PM
Run logon script Sandy22 Operating Systems 6 08-06-2010 10:16 AM
Logon Script Does Not Work c54618 Operating Systems 1 01-05-2008 08: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

All times are GMT +5.5. The time now is 07:50 AM.