{"id":127,"date":"2008-03-27T12:56:39","date_gmt":"2008-03-27T07:26:39","guid":{"rendered":"http:\/\/198.58.113.91\/blog\/adding-the-run-as-administrator-option-for-vbs-and-js-files\/"},"modified":"2019-06-04T05:08:07","modified_gmt":"2019-06-04T05:08:07","slug":"adding-the-run-as-administrator-option-for-vbs-and-js-files","status":"publish","type":"post","link":"https:\/\/www.winhelponline.com\/blog\/adding-the-run-as-administrator-option-for-vbs-and-js-files\/","title":{"rendered":"Add Run as Administrator Context Menu Item for VBS and JS files"},"content":{"rendered":"<p>By default, Windows does not include the <strong>Run as Administrator<\/strong> option in the context menu for Vbscript (.VBS) and JScript (.JS) files. So, to run a script elevated, you either need to launch the script from <a href=\"https:\/\/www.winhelponline.com\/blog\/open-elevated-command-prompt-windows\/\">elevated Command Prompt<\/a> window, or use the VBScript self-elevation method as described in article <a href=\"https:\/\/www.winhelponline.com\/blog\/vbscripts-and-uac-elevation\/\">How to Automatically Elevate a Vbscript to Run it as Administrator?<\/a><\/p>\n<p>Besides that, you can add the <strong>Run as Administrator<\/strong> option to the context menu so that you can run a script elevated from the right-click menu.<!--more--><\/p>\n<h2>Add &#8220;Run as Administrator&#8221; Context Menu option for VBScript and JScript files<\/h2>\n<p>Copy the following contents to Notepad and <a href=\"https:\/\/www.winhelponline.com\/blog\/how-to-use-reg-files-registration-entries-windows\/\">make a .reg file<\/a>. Let&#8217;s say <code>script_runas.reg<\/code><\/p>\n<p>Double-click on the file to apply the settings to the registry. Click Yes when prompted.<\/p>\n<pre>Windows Registry Editor Version 5.00\r\n\r\n[HKEY_LOCAL_MACHINE\\SOFTWARE\\Classes\\VBSFile\\Shell\\runas\\Command]\r\n@=hex(2):22,00,25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,\\\r\n00,25,00,5c,00,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,57,00,\\\r\n53,00,63,00,72,00,69,00,70,00,74,00,2e,00,65,00,78,00,65,00,22,00,20,00,22,\\\r\n00,25,00,31,00,22,00,20,00,25,00,2a,00,00,00\r\n\r\n[HKEY_LOCAL_MACHINE\\SOFTWARE\\Classes\\JSFile\\Shell\\runas\\Command]\r\n@=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,00,25,\\\r\n00,5c,00,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,57,00,53,00,\\\r\n63,00,72,00,69,00,70,00,74,00,2e,00,65,00,78,00,65,00,20,00,22,00,25,00,31,\\\r\n00,22,00,20,00,25,00,2a,00,00,00<\/pre>\n<p>This .reg file adds the <strong>runas<\/strong> command for <code>VBSFile<\/code> and <code>JSFile<\/code> registry keys located here:<\/p>\n<pre>HKEY_CLASSES_ROOT\\VBSFile\\Shell\\runas\r\nHKEY_CLASSES_ROOT\\JSFile\\Shell\\runas<\/pre>\n<p>The hex codes in the above .reg file translate to the following command:<\/p>\n<pre>%SystemRoot%\\System32\\WScript.exe \"%1\" %*<\/pre>\n<p>Now, when you right-click a VBScript or JavaScript file, you&#8217;ll have an option to run it as administrator.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.winhelponline.com\/blog\/wp-content\/uploads\/script_runas.png\" alt=\"add run as administrator context menu for vbs files\" width=\"230\" height=\"99\" \/><\/p>\n<h3>Related Posts<\/h3>\n<ul>\n<li><a href=\"https:\/\/www.winhelponline.com\/blog\/open-elevated-command-prompt-windows\/\">Open an elevated Command Prompt from the folder context menu<\/a><\/li>\n<li><a href=\"https:\/\/www.winhelponline.com\/blog\/vbscripts-and-uac-elevation\/\">Automatically elevate a Vbscript to run it as administrator (using &#8220;runas&#8221;)<\/a><\/li>\n<li><a href=\"https:\/\/www.winhelponline.com\/blog\/register-dlls-elevated-using-the-context-menu\/\">Register DLLs (elevated) using the context menu<\/a><\/li>\n<li><a href=\"https:\/\/www.winhelponline.com\/blog\/add-edit-hosts-file-option-in-the-context-menu\/\">Add \u201cEdit HOSTS file\u201d option in the context menu<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>By default, Windows does not include the Run as Administrator option in the context menu for Vbscript (.VBS) and JScript (.JS) files. So, to run a script elevated, you either need to launch the script from elevated Command Prompt window, or use the VBScript self-elevation method as described in article How to Automatically Elevate a &#8230; <a title=\"Add Run as Administrator Context Menu Item for VBS and JS files\" class=\"read-more\" href=\"https:\/\/www.winhelponline.com\/blog\/adding-the-run-as-administrator-option-for-vbs-and-js-files\/\" aria-label=\"Read more about Add Run as Administrator Context Menu Item for VBS and JS files\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[7],"tags":[441],"class_list":["post-127","post","type-post","status-publish","format-standard","hentry","category-windows","tag-registry"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":347,"url":"https:\/\/www.winhelponline.com\/blog\/windows-installer-errors-2738-and-2739\/","url_meta":{"origin":127,"position":0},"title":"Fix for Windows Installer errors 2738 and 2739","author":"Ramesh","date":"June 28, 2008","format":false,"excerpt":"When you try to install a program using Windows Installer (.msi) Setup package, you may encounter error 2738 or 2739 and the setup fails. Errors 2738, 2739 occur if the Windows Installer Setup uses Windows Script (.vbs or .js) custom actions, and the VBScript or JScript runtimes are not registered\u2026","rel":"","context":"In &quot;Windows&quot;","block_context":{"text":"Windows","link":"https:\/\/www.winhelponline.com\/blog\/category\/microsoft\/windows\/"},"img":{"alt_text":"vbscript and jscript error 2738 and 2739","src":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2008\/06\/vbscript-jscript-2738-2739-errors.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2008\/06\/vbscript-jscript-2738-2739-errors.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2008\/06\/vbscript-jscript-2738-2739-errors.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":1541,"url":"https:\/\/www.winhelponline.com\/blog\/error-there-is-no-script-engine-for-file-extension-when-running-js-files\/","url_meta":{"origin":127,"position":1},"title":"[Fix] There is no script engine for file extension .JS &#8211; Error","author":"Ramesh","date":"January 15, 2007","format":false,"excerpt":"When you attempt to run a .js (JScript Script File) file, one of the following errors may occur: Can't find script engine \"JScript\" for script \"filename.js\". There is no script engine for file extension \".js\". RELATED: [Fix] Can't find Script Engine Vbscript, and \"no script engine for .vbs\" [Fix] There\u2026","rel":"","context":"In &quot;Windows&quot;","block_context":{"text":"Windows","link":"https:\/\/www.winhelponline.com\/blog\/category\/microsoft\/windows\/"},"img":{"alt_text":"There is no script engine for file extension","src":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2007\/01\/js-engine-error.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2007\/01\/js-engine-error.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2007\/01\/js-engine-error.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2007\/01\/js-engine-error.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":235,"url":"https:\/\/www.winhelponline.com\/blog\/error-there-is-no-script-engine-for-file-extension-when-running-vbs-files\/","url_meta":{"origin":127,"position":2},"title":"[Fix] Can&#8217;t find Script Engine Vbscript, and &#8220;no script engine for .vbs&#8221;","author":"Ramesh","date":"April 27, 2008","format":false,"excerpt":"When you run a VBScript or .msi setup file that runs a VBScript, you may receive one of the following errors: Can't find script engine \"VBScript\" for script C:\\ProgramData\\Microsoft\\Windows\\OFFICEICON.vbs There is no script engine for file extension \".vbs\". This happens if the vbscript.dll module is not registered correctly or the\u2026","rel":"","context":"In &quot;Windows&quot;","block_context":{"text":"Windows","link":"https:\/\/www.winhelponline.com\/blog\/category\/microsoft\/windows\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":273,"url":"https:\/\/www.winhelponline.com\/blog\/add-the-open-file-location-context-menu-for-shortcuts-in-windows-xp\/","url_meta":{"origin":127,"position":3},"title":"How to Add &#8220;Open File Location&#8221; Right-Click Option in Windows XP","author":"Ramesh","date":"May 9, 2008","format":false,"excerpt":"Windows Vista and Windows 7 include the Open file location context menu item for Shortcuts, which helps you quickly open the target folder of a shortcut. In Windows XP, it takes four mouse clicks to accomplish the task. To open the target folder of a shortcut in Windows XP, you\u2026","rel":"","context":"In &quot;Windows XP&quot;","block_context":{"text":"Windows XP","link":"https:\/\/www.winhelponline.com\/blog\/category\/microsoft\/windows\/windows-xp\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/opentargetdir.gif?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":123,"url":"https:\/\/www.winhelponline.com\/blog\/add-edit-hosts-file-option-in-the-context-menu\/","url_meta":{"origin":127,"position":4},"title":"Add &#8220;Edit HOSTS file&#8221; option in the context menu","author":"Ramesh","date":"March 26, 2008","format":false,"excerpt":"The HOSTS file, originally introduced to resolve hostnames to IP addresses, is also an effective tool to block Malware. To modify the HOSTS file in Windows, you need to elevate Notepad.exe or any other text editor which you use. Otherwise, you'll see the following error when trying to save the\u2026","rel":"","context":"In &quot;Windows&quot;","block_context":{"text":"Windows","link":"https:\/\/www.winhelponline.com\/blog\/category\/microsoft\/windows\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/hosts3.gif?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":1512,"url":"https:\/\/www.winhelponline.com\/blog\/vbscripts-and-uac-elevation\/","url_meta":{"origin":127,"position":5},"title":"How to Launch a Vbscript in Elevated Mode (Run as Administrator)","author":"Ramesh","date":"April 6, 2007","format":false,"excerpt":"With the introduction of User Account Control (UAC) in Windows Vista, you usually open an elevated Command Prompt in order to run batch files and scripts that need administrative privileges. Applications can make use of manifest files (using the RequireAdministrator flag) to automatically run elevated. For scripts, this article provides\u2026","rel":"","context":"In &quot;Windows&quot;","block_context":{"text":"Windows","link":"https:\/\/www.winhelponline.com\/blog\/category\/microsoft\/windows\/"},"img":{"alt_text":"automatically elevate vbscript runas","src":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2007\/04\/uac-vbscript-elevation.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]}],"_links":{"self":[{"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/posts\/127","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/comments?post=127"}],"version-history":[{"count":0,"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/posts\/127\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/media?parent=127"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/categories?post=127"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/tags?post=127"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}