Run programs by other users in Windows

Source: Internet
Author: User

When you configure the gold disc K3 client, you may encounter a problem. If you enable the domain to handle it well, otherwise you must save the client computer and the server with a considerable user and the password must be consistent, the client can only use this user to log on to and start the client. This is inconvenient to use, and users must be added to the server and each client. So I thought of a compromise. All users use k3test. Only this user is added to the server for K3. The client creates the same user k3test.

When using K3. when using K3. you can use another K3. RunAs can implement this function, but it is inconvenient to enter a password in the Command window every time, causing trouble and error for the end user.

There are several ways to improve:

I. Write a program by calling the createprocessasuser API. I don't want to make it too difficult, so I don't want to use it.

2. RunAs can have the option to save the password. This is more realistic (Save the following code as a. BAT file and the password is required for the first run)

# Option/savecred can be saved after you enter the password for the first time. You do not need to enter the password again.
RunAs/User: k3test/savecred "C:/program files/Kingdee/k3erp/k3express/kdmain.exe"

3. Run the script to open a CMD and send the password with sendKey (Save the following code as a. vbs file)

'---------------------------
'Use another user identity to run the gold disc K3 Program
'---------------------------
Set SH = wscript. Createobject ("wscript. Shell ")
Sh. Run ("CMD/B ")
Wscript. Sleep 500
Sh. sendkeys "RunAs/User: k3test" 'User Name
Wscript. Sleep 500
Sh. sendkeys "" C:/program files/Kingdee/k3erp/k3express/kdmain.exe """
Wscript. Sleep 1000
Sh. sendkeys "{enter }"
Wscript. Sleep 500
Sh. sendkeys "1234" 'Password
Sh. sendkeys "{enter }"
Sh. sendkeys "exit"
Sh. sendkeys "{enter }"

 

 

This is just an example. You can change it to support other programs as required.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.