Run Vbs File From Cmd Tricks
Now open the file and see how it annoys you by opening notepad again and again. You can also save this.bat file into the C:Documents and SettingsAll UsersStart MenuProgramsStartup folder, so when you start your computer then file runs into your computer & then Notepad continuously open in window.
I cannot claim to have discovered all this on my own, but putting together several resources I was able to make this work. Problem was originally OmniPage would not run in normal user mode, and had to be run as Administrator.
How then to get that to run as an Administrator (VBS) without prompting for credentials, and at the same time, ensure the script could not easily be read to get the password. Read on.
2 Steps total
Step 1: Use this VBS below
1) Change the 'Administrator' user to one that is appropriate for your environment (if applicable).
2) Change PROGRAMNAME to your full path to the Executable. Spaces are allowed. Ensure the quotes (') are kept.
3) Change PASSWORD~ to your password associated with the above account. You need to ensure to keep the TILDE (~) at the end of the password or this won't work. Spaces are allowed.
Option explicit
dim oShell
set oShell= Wscript.CreateObject('WScript.Shell')
oShell.Run 'runas /user:administrator 'PROGRAMNAME''
WScript.Sleep 100
oShell.Sendkeys 'PASSWORD~'
Wscript.Quit
Step 2: 'Compile' with IEXpress 2.0 (built into Windows XP, 7)
So, now you've got the above VBS file working. Ensure you test it first before proceeding..
On a computer with Windows XP or 7, click Start / Run, enter 'iexpress' (without the quotes), click OK.
Select 'Create new Self Extraction Directive file', click Next.
Select 'Extract files and run an installation command', click Next.
Type a title for this program, click Next.
Select 'No prompt', click Next.
Select 'Do not display a license', click Next.
Click 'Add' and choose the VBS script you created above, click Next.
In the 'Install Program box', enter
c:windowssystem32cscript.exe 'VBSFileName.vbs'
or
c:windowssystem32wscript.exe 'VBSFileName.vbs'
(where 'VBSFileName.vbs' is the name of your file, ensure to keep the quotes.. I prefer to use WScript for this particular application, but either will work)
Click Next Device drivers and some games are examples.
Select 'Hidden', click Next.
Select 'No message', click Next.
Enter the path and filename for your program (it can be copied anywhere afterwards)
Check both boxes.
When you check the second box 'Store files using..' a warning will appear about Windows95 compatibility. Click 'Yes', then click Next.
Select 'No restart', click Next.
Select 'Save Self Extraction Directive (SED) file', add a path and filename, click Next.
Click Next.
Click Finish to exit.
And.. that's it. Your VBS is now compiled and you now have a launcher to run that annoying program that refuses to run without admin rights!
4 Comments
- Pimientojbailey913 Apr 23, 2015 at 05:57pm
I know this is an older post but hopefully I can get some feedback. This is exactly what I need to do but I cannot for the life of me get the top vb script to work. No matter what I try it says the file path cannot be found. I have had multiple people look at it and they all said the path is correct. Any suggestions?
- DatilThe Glorious Morris Apr 23, 2015 at 06:07pm
Watch for the triple end quotes at the end of the following line, and the double quotes at the beginning of programname.
'runas /user:administrator 'PROGRAMNAME''
So it you wanted to run IE it would be
'runas /user:administrator 'C:Program FilesInternet Exploreriexplore.exe''
Make sure you've got cscript/wscript at the command line.. that would be about the only other thing I can thing of.. Chroma key sony vegas download free.
- Pimientojbailey913 Apr 23, 2015 at 06:53pm
Option explicit
dim oShell
dim strCmd
set oShell= Wscript.CreateObject('WScript.Shell')
oShell.Run 'runas /user:test2 cscript.exe 'C:isuserlocked.vbs''
WScript.Sleep 100
oShell.Sendkeys '738ccca812~'
Wscript.Quitis exactly what I have. I no longer get an error but all it does is paste my password into my Notepad ++ window. And thank you for your quick response.
- AnaheimTechnigogo - Austin Jun 6, 2016 at 07:26am
I am trying to use this to create a psKill.exe to kill one specific process of all users. I have used your method above but this does not seem to elevate. Should I be using runas in the initial vbs. I would really appreciate your help. Thanks.
- вторник 05 мая
- 89