Run an other program as different user

Post Reply
Marc Vanzegbroeck
Posts: 1167
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium
Contact:

Run an other program as different user

Post by Marc Vanzegbroeck »

Hi,

I need to run another program with a different user/password , than my program, from my program.
That other program have to have other right to access a server to get data, but that user/password,can't access the things that my program is using...
Is that possible?
It's something as the RUNAS-dos-command,but that one ask me the password.

Thanks
Regards,
Marc

FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Natter
Posts: 1279
Joined: Mon May 14, 2007 9:49 am

Re: Run an other program as different user

Post by Natter »

If I understood correctly:

There is a general user directory on the server
Full name, password, rights fields

If you run the program from your program, then all this can be passed as parameters
Marc Vanzegbroeck
Posts: 1167
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium
Contact:

Re: Run an other program as different user

Post by Marc Vanzegbroeck »

No, my program can access everything from the PC.

The other user can only access data from another (OPC)-server. Only that user has access to get data from that system.

My program will call the other program(with other credentials), and that program return data(it place data on a specific place that my program can access) , that my program will use.

The reason why only that other user can access the other server, is that this is used in a chemical plant, and the normal user may not access the other server. They give me a login than I can use in my program to access that data, but the users may not know the user/password
Regards,
Marc

FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Natter
Posts: 1279
Joined: Mon May 14, 2007 9:49 am

Re: Run an other program as different user

Post by Natter »

So, specifically, it doesn't work ?
Marc Vanzegbroeck
Posts: 1167
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium
Contact:

Re: Run an other program as different user

Post by Marc Vanzegbroeck »

In the info of the runas-command:
Enter the password when prompted. The RunAs program demands that you type the password manually. This was a conscious design decision. If it were possible to pass the password on the command line, people would start embedding passwords into batch files and logon scripts, which is laughably insecure
There is a possibility to use the /savecred, but the I have to enter the password manualy one time.

I see that the runas() function in Autoit can handle passwords. I will try it.
Regards,
Marc

FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Natter
Posts: 1279
Joined: Mon May 14, 2007 9:49 am

Re: Run an other program as different user

Post by Natter »

RunAs - 'is this the FW or Clipper function ? If you want to enter the password automatically, then find the handle of the window and the item on it. And enter the password(sendmessage) in this element
Marc Vanzegbroeck
Posts: 1167
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium
Contact:

Re: Run an other program as different user

Post by Marc Vanzegbroeck »

No, runas.exe is standard Microsoft commandline-program located in %windir%\System32\runas.exe...

I see that there are different alternative programs for it.
I will try those.
Regards,
Marc

FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Post Reply