Windows XP autostart process as administrator

permissionsscriptingwindows-xp

I am looking for a way with which i can autostart a certain program on logon of a user with user-rights with administrator-rights.

I already tried using task scheduler but it didn't work out because you got to enter a username with format machine\user and our pxe-image-deployment-system automatically patches the machine names so the entered domain\user stopped working.

UPDATE:

the runas.exe command does not seem appropiate for this task, too.
If using /user:machinename\Administrator /savcred it is invalid after imaging.
What one user suggested was using .\Administrator or localhost\Administrator but both didn't work on my XP SP3 machines.

UPDATE2:

In the program i need to execute this function is getting used:

    [DllImport("user32.dll")]
    public static extern int ExitWindowsEx(int uFlags, int dwReserved);

when using the programs suggested by Alan Kuras this function is failing, which is a no-go for me.

UPDATE3:

Yes! I got it, I think!
It seems like you could not use ExitWindowsEx when running under another users context.

I simply switched my application to WTSLogoffSession and now it's working!

Best Answer

If You have problem to achive this task using built-in functions because of Your deployment system there is a solution, which works for many other things like sending someone program which can be run as Administrator without knowing a password.

Basically You need to create program which contains administrator password and can obtain specified rights running as another user. There are several programs which come to my mind:

Those programs can encrypt You script, username and password and automatically run as local administrator in user environment.

Alternatively if You know some programming language You can write it for urself. Just read about impersonate (for example in C#)

Edit 2 : Second thing which come in to my mind. If You have problem obtaining computername You can try to use %COMPUTERNAME% variable like %COMPUTERNAME%\Administrator and check if that works.