Adding Runas to Folder Context Menu
-
Hi All, can any one say me how to add "RunAs" to Folder Context Menu in windows XP... Just Like it works for Exe files. Thanks in Advance
If U Get Errors U Will Learn If U Don't Get Errors U Have Learnt
You can't really 'run' a folder as such, so it won't work in quite the same way. I'd say you'd need to do one of two things: 1) Write a context menu shell extension in your language of choice. Google for "context menu shell extension" and there should be loads of help. 2) This is a cowboy approach. Create a vbscript to do the job for you. Put this in it:
'grab the username sUsername = InputBox("Enter Username") 'create a shell command object set oCmd = createobject("Wscript.Shell") 'Build the runas string passing the folder name to explorer.exe sCmd = "runas /u:" & sUsername & " " & chr(34) & "explorer " & wscript.arguments(0) & chr(34) 'Run the command oCmd.run sCmd
Save it in your c:\documents and settings\%username%\sendto folder (show hidden files and folders to see this folder). Now when you right-click the folder, you should see your script under the 'Send To' context menu. If you select it, you'll get an inputbox prompt for the username, a dos prompt for the password, and it should open the folder using that user's credentials for you. It's a messy lash, but it works. -
You can't really 'run' a folder as such, so it won't work in quite the same way. I'd say you'd need to do one of two things: 1) Write a context menu shell extension in your language of choice. Google for "context menu shell extension" and there should be loads of help. 2) This is a cowboy approach. Create a vbscript to do the job for you. Put this in it:
'grab the username sUsername = InputBox("Enter Username") 'create a shell command object set oCmd = createobject("Wscript.Shell") 'Build the runas string passing the folder name to explorer.exe sCmd = "runas /u:" & sUsername & " " & chr(34) & "explorer " & wscript.arguments(0) & chr(34) 'Run the command oCmd.run sCmd
Save it in your c:\documents and settings\%username%\sendto folder (show hidden files and folders to see this folder). Now when you right-click the folder, you should see your script under the 'Send To' context menu. If you select it, you'll get an inputbox prompt for the username, a dos prompt for the password, and it should open the folder using that user's credentials for you. It's a messy lash, but it works.