To run VBScript file, follow these steps. I have tested on my Windows Server 2016 but it should run on other windows versions.
Open PowerShell or command prompt with elevated privileges.
Normally, when you run a Windows Scripting Host file such as a Visual Basic or Java script, Explorer WSCRIPT.EXE is executed and runs the script using the necessary script plug-in. To run from the command line, use CSCRIPT.EXE which has a number of optional parameters as follows.
Execute the following command:
cscript <VBScript file name>
For example, to run hello.vbs, which is located in your current working directory:
cscript hello.vbs
or
cscript <Full path of VBScript fie>
For example, to run hello.vbs which is not located in your current working directory:
cscript C:UsersAdministrator.Desktophello.vbs
How-To Geek Forums / Windows 7
(Solved) - Make a batch file to run cmd as administrator
(14 posts)In window 7 and vista, i want to make a batch file that run command as administrator, help me...?
I don't think it is actually possible.
I am hoping to be proven wrong though!! :D
Well, check here, ON HOW TO DO THIS. This will open a COMMAND prompt that is running as Administrator and will run all the BAT file commands as an Administrator.
I think you can do the SAME thing by putting a link/shortcut (icon) for BAT file on your desktop and then Right Mouse Button on the icon and selecting RUN AS ADMINISTRATOR.
Irv S.
if you make the .bat into a .exe with this tool, then you can make it run as admin.
BTW why not use VB Script ?
Then there is also Create Administrator Mode Shortcuts Without UAC Prompts in Windows 7 or Vista if that is what you mean.
What I did was this:
1. Make a shortcut pointed to the command prompt (I named it Administrative Command Prompt)
2. Open the shortcut's properties and go to the Compatibility tab
3. Under the Privilege Level section, make sure the checkbox next to 'Run this program as an administrator' is checked
1. Make a shortcut pointed to the command prompt (I named it Administrative Command Prompt)
2. Open the shortcut's properties and go to the Compatibility tab
3. Under the Privilege Level section, make sure the checkbox next to 'Run this program as an administrator' is checked
But as I'm reading it, the op wants to click a batch file and it will run in cmd prompt in administrator mode. Apart from physically opening cmd prompt in Admin mode and entering the bat file name, I don't think that it is possible.
Well, after zs474's answer, there is a way, but not through normal methods.
Make a batch file in an editor and nameit.bat then create a shortcut to it. Nameit.bat - shortcut. then right click on Nameit.bat - shortcut ->Properties->Shortcut tab -> Advanced and click Run as administrator. Execute it from the shortcut.
@Xhi, you try that? On my W7 x64 doing so has the choice grayed out?
Irv S.
It will be grayed out if one is running as Built in Administrator and gives themselves all privileges plus special permissions, ownerships, etc., etc..
That's what I do to keep the annoyances away. (lol) :) :)
EDIT: I do NOT recommend this method of Windows 7 operation.
![2012 2012](/uploads/1/2/6/2/126228951/542588613.png)
Rick P.
Try using 'runas /user:administrator C:datamybatchfile.bat'
Thanks Xhi thats so cool tip it works as i want...thanks a lot..:)
Topic Closed
This topic has been closed to new replies.