Hey Everyone I'm trying to make a simple VBS script and I keep getting Error bject required:'WshShell'
Here is the script
CreateObject("WScript.Shell").Run "C:\DEXIS\DEXsync.exe"
WScript.Sleep 1000
WshShell.SendKeys "{ENTER}"
WScript.Quit()
I have also attached the error message. can someone please help I feel like i'm taking crazy pills
error message
You'll need to set that WshShell variable you are using to a new Wscript.Shell object. Try something like this instead:
Set WshShell = CreateObject("WScript.Shell")
WshShell.Run "C:\DEXIS\DEXsync.exe"
WScript.Sleep 1000
WshShell.SendKeys "{ENTER}"
WScript.Quit()
Related
How to use VBScript to open notepad and paste current date in it?
This is all I have for now:
Set WshShell = WScript.CreateObject("WScript.Shell")
Call WshShell.Run("%windir%\system32\notepad.exe")
Dim aDate
aDate = Date()
WScript.Sleep 2000
Now, how do I paste the date?
Use SendKeys to send keystrokes to the active window.
Usage:
WshShell.SendKeys aDate
You may need to ensure that the focus is in the window you want to send keystrokes to. For this, use AppActivate method.
Using window title in this case:
WshShell.AppActivate "Untitled - Notepad"
You can also use
WshShell.SendKeys "{F5}"
I know i am late, but try the following code, it works:
Set wshshell = wscript.CreateObject("WScript.Shell")
Wshshell.run "Notepad"
wscript.sleep 100
dim aDate
aDate = Date()
wscript.sleep 2000
wshshell.sendkeys aDate
wscript.sleep 1000
Make sure the extension of the file is ".vbs"
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
Set WshShell = WScript.CreateObject("WScript.Shell")
WScript.Sleep 500
WshShell.SendKeys "{BREAK}"
I want run as Pause|Break keys, How can I set it?
I need to Automate the Whole Process, So the Cmd Prompt opens and path is set there for the .bat file to open
I have tried with Window Shell Commands to do this .. they work fine .. But i need some other way to open and set the path to run the file ..can anyone help me
Thanks In Advance
Here you go
Set WshShell = wscript.CreateObject("wscript.Shell")
WshShell.Run "cmd"
WScript.Sleep 100
WshShell.AppActivate "C:\Windows\system32\cmd.exe"
WScript.Sleep 100
wshshell.sendkeys "c:\path"
wshshell.sendkeys "{ENTER}"
wshshell.sendkeys "SET PATH=%PATH%;c:\tmp"
wshshell.sendkeys "{ENTER}"
wshshell.sendkeys "batch.cmd"
wshshell.sendkeys "{ENTER}"
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