Application Modernization: What Is It and How to Get Started
The runasv program offers execution commands for every user running Windows NT and Windows 2000.
This program allows the execution of every command with the user specified. The runserv.exe program runs as a service (with localsystem user) and listens by using Windows sockets (port 8000) as a server application. When it receives some information through this port, it works with this information, formatting it, and it obtains the command to execute the user and password, and the execution mode. Then, it uses the LogonUser API function to change the user to the user specified and execute the command. When this command finishes, it sends the reply to the client application. The runasv.exe program runs as a client application by using Windows sockets and sends the request through port 8000. It formats the input parameters, builds a message, and sends this message to the server application (runserv.exe) that runs as a system service. Then, it waits for the reply.
- It enables you to incorporate passwords as input parameters. In this case, it doesn't ask for a password. You can use this utility in batch processes without stoping the process.
- You can execute commands in remote machines by specifying the machine name or IP address as an input parameter.
There is no utility similar to runas in Windows NT; these programs can be useful with this operating system.
To use these programs:
- -c: Creates service runserv.
- -b: Deletes service runserv.
runasv <Command> [-h] <Machine> <User> <Password>
- <Command>: command to execute.
- [-h]: specify hide execution (optional).
- <Machine>: name or IP address of execution machine (if you don't specify this parameter, the execution will be local).
- <User>: user for executing (you can specify the domain, too).
- <Password>: user's password.
If you don't specify a user and password, the application will ask for them. Example:
runasv "net stop PrManager" \DomainTest\administrator vvvpass
These programs can be interesting for two reasons:
- Its practical use is for doing several tasks as administrator with users without privileges (you don't need to logoff and a issue a new logon with an administrator user), especially with Windows NT.
- It is a complete example of Windows sockets, services, and processes management.
These programs were compiled and linked with Microsoft Visual C++ 6.0.