Windows Tip: Running scripts using alternate credentials
Send your Windows question to Mitch today! | See other Windows tips
On Windows XP and Windows Server 2003, you can run a program using different credentials than those of the currently logged-on user. Administrators often use this Secondary Logon feature to increase the security of their workstations by running as an ordinary domain user for most purposes such as browsing the Web and checking email. Then, when you need to open an administrative tool like dsa.msc, you either open a command prompt and use runas mmc.exe to launch the .msc file or you right-click on the .msc file itself and select Run As from the shortcut menu.
But what if you want to run a VBScript script using alternate credentials? You can use the runas command from a command prompt, but unfortunately right-clicking on a .vbs file doesn't bring up a Run As option in the shortcut menu. It sure would be nice if you could add this menu option, but how? Well, where there's a script, there's a way, so here's a script you can use to add the Run As option to the shortcut menu when you click on .vbs files:
strReg = "HKCR\VBSFile\Shell\RunAS\"
strReg1 = "HKCR\VBSFile\Shell\RunAS\Command\"
strValueDEF = "&Run As ..."
strValue = "runas.exe ""%1"""
Set objShell = CreateObject("WScript.Shell")
objShell.RegWrite strReg,strValueDEF,"REG_SZ"
objShell.RegWrite strReg1,strValue,"REG_SZ"
Just paste this script into Notepad and save it as AddVbsRunas.vbs, then double click on the script to run it. Now, try right-clicking on the script and you'll see the Run As option is now available for .vbs files.
My thanks to Ed Wilson for providing this script. Ed is a senior consultant at Microsoft and a scripting expert who has written several books including his most recent title Microsoft Windows PowerShell Step By Step from Microsoft Press. Ed also wrote most of the scripts found on the Companion DVD of the Windows Vista Resource Kit, a popular title for which I was the lead author -- just some more shameless self-promotion on the part of a starving author, heh.
ITworld.com
Symantec Backup Exec 12 and Backup Exec System Recovery 8 deliver industry leading Windows data protection and system recovery. Download this whitepaper to find out the top reasons to upgrade and how to get continuous data protection and complete system recovery.
Data and system loss — from a hard drive failure, malicious attack, natural disaster, or simple human error — can happen anytime. Don’t leave your business vulnerable. Make sure you have a secure recovery strategy in place. Symantec's latest backup and system recovery technology can efficiently restore critical applications, individual emails and documents and even restore your entire system in minutes in the event of a loss.
Businesses face a growing challenge to ensure that the IT environment is properly protected. Backup Exec 12 integrates with other applications in the Symantec family of products, to complement your current data protection strategy, keep your data securely backed up and make it recoverable when you need it most.







