Hello,

I have used the following article to create N local users:

http://www.codeproject.com/KB/system/everythingInAD.aspx?msg=3448333#xx3448333xx

How do I set some batch file ,that I have wrote ,to be executed right when each user logs-in?

(Include it in the statup functions to be executed).

Cheers,

You could use the "Startup" folder for a user. Be aware that folder will be at different locations based on the OS being used (XP, Vista, Windows 7, etc.)

However, even though your scripts are written in C#, you may get more answers if you post this in the "Microsoft Windows" forum.

You could use the "Startup" folder for a user. Be aware that folder will be at different locations based on the OS being used (XP, Vista, Windows 7, etc.)

However, even though your scripts are written in C#, you may get more answers if you post this in the "Microsoft Windows" forum.

I want to run the script only for users which aren't connected to the domain.
I don't want to restart the machine to run the script. (So I cannot just put the script in the "start folder".
===

My batch file only write the SessionID (from environment variable) to a local eventlog.

I want to 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.

Any ides?

Best Regards,

More details:

the batch I wrote only writes an eventlog with message: SessionID = %SessionName%.


I want to run the script only for users which aren't connected to the domain.
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.

?


Best Regards,

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.