VBScript to open, run and close Tor browser - vbscript

Please edit this VBScript to open, run and close Tor browser:
Dim objShell
Set objShell = WScript.CreateObject("WScript.Shell")
objShell.Exec("""C:\Users\Name\Desktop\Tor\Tor Browser\Browser\Tor.exe""/http://www.google.com")
Set objShell = Nothing
WScript.Sleep 20000
Set objShell = objshell.Exec("taskkill /fi ""imagename eq Tor.exe""")
It opens and runs, but doesn't close.

You should try something like this :
Dim objShell
Set objShell = CreateObject("WScript.Shell")
objShell.Run "Taskkill /F /IM Tor.exe",0,True

Related

VBS Windows proxy enable

Option Explicit
Dim objShell, RegLocate
Set objShell = WScript.CreateObject("WScript.Shell")
RegLocate = "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyEnable"
objShell.RegWrite RegLocate,"0","REG_DWORD"
WScript.Sleep 1000
If "REG_DWORD" = "" then
CreateObject("WScript.Shell").RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet\Settings\ProxyEnable Settings\ProxyEnable",1,"REG_DWORD"
else
MsgBox "Proxy alrdy running"
end if
WScript.Quit
So my problem is not to get the proxy settings in, I have script for that and it works. The problem is to enable it in IE explorer.
The script runs and don't get an error... so I have hit a wall.
Sorry for bad grammar and English.

How to stop a specific script in VBScript

Is there a code to stop a specific script? I've seen a way that allows you to end all scripts using taskkill.
Option Explicit
Dim WshShell
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "taskkill /f /im Cscript.exe", , True
WshShell.Run "taskkill /f /im wscript.exe", , True
I simply want to end one specific script that is sleeping in a wscript.sleep not every script that is running at a time.
Try below. You need to preserve the ProcessId of the process you want to kill. Below code opens a notepad and kills it. This example shows you how to capture the ProcessId of the script when it was started and then kill it.
Private Sub KillTest()
Dim killCmd
Dim pid
Set WshShell = CreateObject("WScript.Shell")
Set EngineRun = WshShell.Exec("notepad")
pid = EngineRun.ProcessID
killCmd = "taskkill /pid " & CStr(pid)
Set EngineRun = WshShell.Exec(killCmd)
Set EngineRun = Nothing
Set WshShell = Nothing
End Sub

How to open webpage in VBS

My code is
Set WshShell = CreateObject("WScript.shell")
for i = 0 to 50
WshShell.SendKeys(chr(175))
next
Process.Start("CMD", "/C start chrome.exe http://www.example.com")
It sets the volume to full, then opens chrome to example.com. But when I run it I get this error:
Cannot use parentheses while calling a Sub
How can I get it to raise the volume, and go to the webpage?
Try like this way :
Option Explicit
Dim URL,WshShell,i
URL = "www.yahoo.com"
Set WshShell = CreateObject("WScript.shell")
For i = 0 to 50
WshShell.SendKeys(chr(175))
Next
WshShell.run "CMD /C start chrome.exe " & URL & "",0,False
wshshell.run "www.youtube.com"
VBScript requires the CALL keyword when calling a sub with parenthesis. You can either write the code like this:
Set WshShell = CreateObject("WScript.shell")
For i = 0 To 50
WshShell.SendKeys Chr(175)
Next
Process.Start "CMD", "/C start chrome.exe http://www.example.com"
...or like this:
Set WshShell = CreateObject("WScript.shell")
For i = 0 To 50
Call WshShell.SendKeys(Chr(175))
Next
Call Process.Start("CMD", "/C start chrome.exe http://www.example.com")
Note: you don't get this error when calling a function and using its return value, like this:
Dim strTest
strTest = SomeFunction()
...because VBScript always requires the parenthesis when a function is used in an assignment.
This way works for me.
set wshshell = wscript.CreateObject("wscript.shell")
wshshell.run "chrome.exe https://stackoverflow.com"
You can change chrome.exe to whatever browser or the website to whatever you want

Simple VBScript to open a application not working

here is my VBScript
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "C:\Program Files\TrueCrypt\TrueCrypt.exe", 0 , false
It says it can't find it.
Taken from here
You can get around this by surrounding the path in quotes. But to do so, you need to escape them correctly(with "), so:
WshShell.Run """C:\Program Files\TrueCrypt\TrueCrypt.exe"""
Either put more quotes around the path, or use the old style string for "Program Files" - Progra~1.
The following example works on my machine:
<package>
<job id="truecrypt">
<script language="VBScript">
set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run """C:\Program Files\TrueCrypt\TrueCrypt.exe""", 0 , false
</script>
</job>
</package>
You can try the following:
Dim objShell
Set objShell = WScript.CreateObject( "WScript.Shell" )
objShell.Run("""C:\Program Files\TrueCrypt\TrueCrypt.exe""")
Set objShell = Nothing

Change Wallpaper in Windows 7

I have written a small vbs script to download and change the registry for the current users wallpaper. however it copies and does the change but the wallpaper does not change... any ideas on errors in the below code?
Option Explicit
Dim WshShell, strValue, sleepTime, oFSO
strValue = "C:\wallpaper.bmp"
sleepTime = 30000
Set oFSO = CreateObject("Scripting.FileSystemObject")
oFSO.CopyFile "\\anspksnms1\OSD\Scripts\wallpaper\wallpaper.bmp", "C:\"
Set WshShell = WScript.CreateObject("Wscript.Shell")
WshShell.RegWrite "HKCU\Control Panel\Desktop\Wallpaper", strValue
WScript.Sleep sleepTime
WshShell.Run "%windir%\System32\RUNDLL32.EXE user32.dll, UpdatePerUserSystemParameters", 1, False
Set WshShell = Nothing
I'm not much of a vbscripter, but maybe try this?
wshShell.run "cmd /c RunDll32.exe USER32.DLL,UpdatePerUserSystemParameters", 1, True

Resources