How to make Windows software work like another user in a script?

I use a build script that calls Wise to create some installation files. The problem is that the Wise license allows you to run it only under one user account, which is not the same account that my version of the script will work with. I know that Windows has a runas command, but this will not work for an automated script, since it is not possible to enter a password through the command line.

+4
source share
4 answers

I recommend a look at CPAU .

A command line tool to start a process in an alternate security context. This is basically a replacement for runas. It also allows you to create task files and encode the identifier, password, and command line in the file so that it can be used by ordinary users.

You can use it like this ( examples ):

CPAU -u user [-p password] -ex "WhatToRun" [switches] 

Or you can create a ".job" file in which the user and password will be encoded inside it. This way you can avoid having to enter a password for the user inside your build script.

+2
source

This is a bit of a workaround, but you can create a scheduled task that runs as your user account and run it regularly, maybe once a minute. Yes, you have to wait until it starts.

This task can then search for some data files for processing and do the real work only if they exist.

+1
source

It may help, this is a class that I used in another project so that people can create their own accounts; everyone should have access to the program, but the same account could not have access to LDAP materials, so the program uses this class to run it as another user.

http://www.codeproject.com/KB/dotnet/UserImpersonationInNET.aspx

0
source

Source: https://habr.com/ru/post/1276902/


All Articles