Case Study: Running Applications as Another User

Suppose you are an administrator, and you sometimes have to log on to your machine as another user to test for security permissions and such. You can log off of your workstation and log on as that user, but this would require you to close all your applications. Assume, for the sake of argument, that your work habits are like mine, and you have 50 or so windows open, all running different, seemingly important processes. This makes logging off a bit undesirable.

You decide to let Win32 Perl help you out of this dilemma, so you use a Perl script that will impersonate the user and run a program as that user. The script in Example 8.9 provides this functionality.

Example 8.9. Running an application ...

Get Win32 Perl Programming: The Standard Extensions, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.