VBS file to start bat.file - vbscript

I was able to opened my gmail but tried to open next url a. Can I do that? How?
Need to fix right one ( WshShell.Exec "C:\test.bat" )
'Script starts here
Set WshShell = WScript.CreateObject("WScript.Shell")
'Wait 1 second (1000 ms)
WScript.Sleep 1000
'Open IE and go to gmail.com (your IExplore.exe file location may be different)
WshShell.Exec "C:\Program Files\Internet Explorer\IEXPLORE.EXE gmail.com"
'Allow time for IE to finish loading (about 15 secs for slow connections/machines)
WScript.Sleep 10000
'Send the login info in the login box
'login (change username to your login name
WshShell.Sendkeys "xxxxxxxxxx"
WScript.Sleep 500
'hit TAB key to move to password field
WshShell.Sendkeys "{TAB}"
WScript.Sleep 500
'Send the password info
'change your password to your login password
WshShell.Sendkeys "xxxxxxxxxxxxx"
WScript.Sleep 500
'Hit 'Enter' key to log-in
WshShell.Sendkeys "{ENTER}"
WScript.Sleep 10000
WshShell.Exec "C:\test.bat"
'Allow time for IE to finish loading (about 15 secs for slow connections/machines)
WScript.Sleep 15000
'Send the login info in the login box
'login (change username to your login name
WshShell.Sendkeys "xxxxxxxxx"
WScript.Sleep 500
'hit TAB key to move to password field
WshShell.Sendkeys "{TAB}"
WScript.Sleep 500
'Send the password info
'change your password to your login password
WshShell.Sendkeys "xxxxxxxx"
WScript.Sleep 500
'Hit 'Enter' key to log-in
WshShell.Sendkeys "{ENTER}"

EDIT: This worked for me.
test.vbs
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Exec "test.bat"
and test.bat
#echo off
start www.yahoo.com

Related

Fill text in selected field from active window - VBScript, WScript.Shell

I use vbs to upload files into SAP. After clicking "add file" in sap I have the following window on the screen.
I can't control that window using SAP Object so I use WScript.Shell. My question is - how to paste text (file path) to the field "File name:"? I was using wshShell.SendKeys "{TAB}" to jump from one field to another and paste file path, but somehow it doesn't work always. How to get control over that field "File name:" directly and edit it's value?
My code here:
Set wshShell = CreateObject("WScript.Shell")
filePath = "C:\image.png"
wshShell.AppActivate("Storing Files in Documents")
WScript.sleep 200
wshShell.SendKeys "{TAB}"
WScript.sleep 200
wshShell.SendKeys filePath
WScript.sleep 200
wshShell.SendKeys "{ENTER}"
WScript.Quit
Regards

I want to set IE as default browser in windows 10 by vb.net code or any exe. I have used below VBS script. But it is not working

I have tried below script but not working. If it run manually, focus is correct. But if it is run through registry it is not taking focus to desired window. U can also suggest me if there is any other way to keep focus on desired window. The window opened through this code is control panel settig window and it is not found under proccess in task magager.
So please give solution.
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "%windir%\system32\control.exe /name
Microsoft.DefaultPrograms /page pageDefaultProgram\pageAdvancedSettings?
pszAppName=Internet%20Explorer"
'Give Default Programs time to load
WScript.Sleep 500
WshShell.AppActivate "Set Program Associations"
WshShell.SendKeys "{TAB}"
WshShell.SendKeys " "
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{TAB}"
WshShell.SendKeys " "
Msgbox "Default Browser: Internet Explorer"
WScript.Quit
function Set-IEAsDefaultBrowser {
Add-Type -AssemblyName 'System.Windows.Forms'
Start-Process $env:windir\system32\control.exe -ArgumentList '/name Microsoft.DefaultPrograms /page pageDefaultProgram\pageAdvancedSettings?pszAppName=Internet%20Explorer'
Sleep 2
[System.Windows.Forms.SendKeys]::SendWait("{TAB} {TAB}{TAB} ")
}
Set-IEAsDefaultBrowser
I tried to run this script in windows powershell for set Internet Explorer as default Browser. It's works fine.
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "%windir%\system32\control.exe /name Microsoft.DefaultPrograms /page pageDefaultProgram\pageAdvancedSettings?pszAppName=Internet%20Explorer"
WScript.Sleep 1500
WshShell.SendKeys "{TAB}"
WshShell.SendKeys " "
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{TAB}"
WshShell.SendKeys " "
Msgbox "Default Browser: Internet Explorer"
WScript.Quit
it works fine for me.

vbscript auto form submition failed

Hi I have the following vb script that opens a Program, then clicks an ok button on a pop up message then enters a form with server name, user name and password and then clicks submit. The script works well as i have it running as a scheduled logon script.
However if the user opens another window as this script is running then the script fails. I need o make the script a bit more intelligent by focusing on the correct window. Please help.
Dim objShell
Set objShell = WScript.CreateObject( "WScript.Shell" )
objShell.Run("""C:\Program Files (x86)\SNS EVO ShareBrowser\Client\evo ShareBrowser.exe""")
WScript.Sleep 1000
objShell.SendKeys "{ENTER}"
WScript.Sleep 1000
objShell.SendKeys "abc"
objShell.SendKeys "{TAB}"
objShell.SendKeys "user"
objShell.SendKeys "{TAB}"
objShell.SendKeys "password"
objShell.SendKeys "{ENTER}"
wscript.Quit

How can I make a vbs file which can press arrow keys?

I'm using a voice command software and its still in its beta but really good
The only thing that I find a big problem is navigation in folders and files
So i thought i'll make a vbs script with gets triggered to my voice.
eg: I say left the vbs file which presses left arrow gets pressed
I just need the code for the keystrokes
Once again, move the highlighted folder by pressing arrow keys it what i'm trying to do
Plz somebody help me make a code for this
Thank you
may this will help you to create script
'create shell script object which key stork and move arround the screen
set WshShell = WScript.CreateObject("WScript.Shell")
Set shell = wscript.CreateObject("Shell.Application")
shell.Open "C:\export\script"
WshShell.SpecialFolders("C:\export\script")
WshShell.specialFolders.item(0)
WshShell.SendKeys "{LEFT}"
WScript.Sleep 1000
WshShell.SendKeys "{LEFT}"
WScript.Sleep 1000
WshShell.SendKeys "{RIGHT}"
WScript.Sleep 1000
WshShell.SendKeys "{DOWN}"
WScript.Sleep 1000
WshShell.SendKeys "{DOWN}"
WScript.Sleep 1000
WshShell.SendKeys "{DOWN}"
WScript.Sleep 1000
WshShell.SendKeys "{RIGHT}"
WScript.Sleep 1000
WshShell.SendKeys "{RIGHT}"
WScript.Sleep 1000
WshShell.SendKeys "{RIGHT}"
WScript.Sleep 1000
WshShell.SendKeys "{RIGHT}"
WScript.Sleep 1000
WshShell.SendKeys "{RIGHT}"
WScript.Sleep 1000
WshShell.SendKeys "{LEFT}"
WScript.Sleep 1000
WshShell.SendKeys "{UP}"
WScript.Sleep 1000

Loop IP address substitution in prewritten code

I have code set up to telnet into a switch and tftp the startup-config to a server. This code works perfect if I hard code the IP address into the script.
What I would like to do is pass a list of IP addresses (one after the other) to the script so that I can copy all switch configs on the network. I have included some code below, this is the code I used to create the script. All I want to be able to do is replace the "telnet xx.xx.xx.xx" xx.xx.xx.xx entry with a list of IP addresses.
Thanks in advance!
Here is a copy of code I used:
Option Explicit
On Error Resume Next
Dim WshShell
set WshShell=CreateObject("WScript.Shell")
WshShell.run "cmd.exe"
WScript.Sleep 1000
'Send commands to the window as needed - IP and commands need to be customized
'Step 1 - Telnet to remote IP'
WshShell.SendKeys "telnet xx.xx.xx.xx"
WshShell.SendKeys ("{Enter}")
WScript.Sleep 1000
'Step 2 - Issue Commands with pauses'
WshShell.SendKeys ("{Enter}")
WScript.Sleep 1000
WshShell.SendKeys "5"
WshShell.SendKeys ("{Enter}")
WScript.Sleep 1000
'Step 3 - Exit Command Window
WshShell.SendKeys "exit"
WshShell.SendKeys ("{Enter}")
WScript.Quit
Try this, mostly your code with just a few lines inserted to loop through a list of IP addresses in plain text format. Please let me know if this works for you. Doing it this way opens a new command window for each telnet host and then closes it when its done. It would probably be easy to modify to use the same command window.
Option Explicit
On Error Resume Next
Dim WshShell
Dim objFSO
Dim objInputFile
Dim strIP
set WshShell=CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objInputFile = objFSO.OpenTextFile("IPFilelist.txt", 1)
Do Until objInputFile.AtEndofStream
strIP = objInputFile.ReadLine
WshShell.run "cmd.exe"
WScript.Sleep 1000
'Send commands to the window as needed - IP and commands need to be customized
'Step 1 - Telnet to remote IP'
WshShell.SendKeys "telnet " & strIP
WshShell.SendKeys ("{Enter}")
WScript.Sleep 1000
'Step 2 - Issue Commands with pauses'
WshShell.SendKeys ("{Enter}")
WScript.Sleep 1000
WshShell.SendKeys "5"
WshShell.SendKeys ("{Enter}")
WScript.Sleep 1000
'Step 3 - Exit Command Window
WshShell.SendKeys "exit"
WshShell.SendKeys ("{Enter}")
Loop
WScript.Quit

Resources