Is there some way to export contacts from Thunderbird in CSV silently by using script, so we won't have to do it manually for every user?
My intention is to move all gathered addresses (stored in history.mab) from Thunderbird to Outlook 2013 on multiple stations.
After some research, there is probably no straight way how to do it.
I have ended up with this simple macro, which start Thunderbird and via adress book export selected contact list into CSV - far from ideal, but it works in most cases. (only works as intended with constant amount of lists)
SET oShell = CreateObject( "WScript.Shell" )
oShell.Run """C:\Program Files (x86)\Mozilla Thunderbird\thunderbird.exe"""
WScript.Sleep 10000 ' wait a bit for opening Thunderbird
oShell.SendKeys "^+b" 'open address book
WScript.Sleep 2000
oShell.SendKeys "{TAB}{TAB}"
oShell.SendKeys "{DOWN}"
oShell.SendKeys "%n"
oShell.SendKeys "x"
WScript.Sleep 2000
oShell.SendKeys "thunderbird_export_" & username & "" 'name your CSV
WScript.Sleep 1000
oShell.SendKeys "{TAB}"
oShell.SendKeys "{DOWN}{DOWN}"
oShell.SendKeys "{ENTER}"
WScript.Sleep 1000
oShell.SendKeys "^l"
WScript.Sleep 1000
oShell.SendKeys "u:{ENTER}" 'set destination folder
WScript.Sleep 1000
oShell.SendKeys "%u"
WScript.Sleep 1000
oShell.SendKeys "{ENTER}"
WScript.Sleep 1000
' close both adress book and Thunderbird
oShell.Run("taskkill /im thunderbird.exe")
WScript.Sleep 1000
oShell.Run("taskkill /im thunderbird.exe")
WScript.Quit
Related
My script launches a MS Edge window and then tries to log into Netflix with my credentials. The problem is, at times, the browser window comes up behind the CMD console and the script doesn't work.
How do I launch the browser in the foreground or bring it to the foreground after it's launched?
<!-- :
rem #Echo Off
Set "usr_name=#####"
Set "usr_pass=#####"
%SystemRoot%\System32\cscript.exe //NoLogo "%~f0?.wsf" "%browser%" "%usr_name%" "%usr_pass%"
Exit /B
-->
<Job>
<Script Language="VBScript">
Dim ObjShell, MyChrome
Set ObjShell = WScript.CreateObject("WScript.Shell")
MyChrome = Chr(34) & WScript.Arguments(0) & Chr(34)
ObjShell.Run MyChrome & "--app=""https://www.netflix.com/login""", 1
WScript.Sleep 5000
ObjShell.SendKeys "{TAB}"
ObjShell.SendKeys "{TAB}"
ObjShell.SendKeys(WScript.Arguments(1))
ObjShell.SendKeys "{TAB}"
ObjShell.SendKeys(WScript.Arguments(2))
ObjShell.SendKeys "{ENTER}"
WScript.Sleep 6000
ObjShell.SendKeys "{ESCAPE}"
ObjShell.SendKeys "{TAB}"
WScript.Sleep 1000
ObjShell.SendKeys "{TAB}"
WScript.Sleep 1000
ObjShell.SendKeys "{ENTER}"
WScript.Sleep 6000
ObjShell.SendKeys "%{F4}"
</Script>
</Job>
Scripts that depend on SendKeys are notoriously unreliable. A more reliable approach is to control the browser with Seleniumbasic and Chrome driver or use WebView2 in a C# program. Barring that, one option for adding window control functionality to your existing script is to use the command line tool Cmdow. For example:
ObjShell.Run "cmdow ""Netflix*"" /MAX",1,False
Update:
You can also try the built-in AppActivate method:
ObjShell.AppActivate "Netflix"
The solution to to use a powershell cmdlet to minimize all windows before running the script that launches the browser.
'''powershell -command "(new-object -com shell.application).minimizeall()'''
I am trying to automate the Group Policy editing process as much as possible.
I have the following script to spawn the gpedit.msc process but it's window goes out of focus as soon as it opens:
FINDSTR /E "'VbsCode" %~f0 > %temp%\~temp.vbs
CSCRIPT //NOLOGO %temp%\~temp.vbs
Sub GPEditOptions 'VbsCode
On Error Resume Next 'VbsCode
Set WshShell = WScript.CreateObject("WScript.shell") 'VbsCode
WshShell.Visible = False 'VbsCode
WshShell.Run "gpedit.msc",0 'VbsCode
:: WshShell.AppActivate "Local Group Policy Editor" 'VbsCode
End Sub 'VbsCode
GPEditOptions 'VbsCode
:: WScript.Quit 0 'VbsCode
How can I AppActivate the window that has been opened by the newly spawned gpedit.msc process ? Specifically how to know what's the name/title of that window that has been opened ? "Local Group...Editor" doesn't work.
I think I eventually figured out, how to approach this problem. There are different types of processes.
In this case, I first need to select the Microsoft Management Console window, since it's the parent process which spawns the actual "Local Group Policy Editor" child process.
So this code does the job of selecting the first Windows Component starting with letter "W" by sending a ton of keys priorly, and yes you do need Administrator elevation for proper selection of options in the gpedit.msc window:
#echo off
net file 1>nul 2>nul
if not '%errorlevel%' == '0' (
powershell Start-Process -FilePath "%0" -ArgumentList "%cd%" -verb runas >nul 2>&1
exit /b
)
cd /d %1
FINDSTR /E "'VbsCode" %~f0 > %temp%\~temp.vbs
CSCRIPT //NOLOGO %temp%\~temp.vbs
Sub GPEditOptions 'VbsCode
On Error Resume Next 'VbsCode
Set WshShell = WScript.CreateObject("WScript.shell") 'VbsCode
WshShell.Visible = False 'VbsCode
WshShell.Run "gpedit.msc",0 'VbsCode
WScript.Sleep 500 : WshShell.AppActivate "Microsoft Management Console" 'VbsCode
WScript.Sleep 500 : WshShell.AppActivate "Local Group Policy Editor" 'VbsCode
WScript.Sleep 500 : WshShell.sendKeys "% x{TAB}{ENTER}" 'VbsCode
WScript.Sleep 500 : WshShell.sendKeys "{TAB}{TAB}{TAB}{TAB}" 'VbsCode
WScript.Sleep 500 : WshShell.sendKeys "{DOWN}{DOWN}{ENTER}" 'VbsCode
WScript.Sleep 500 : WshShell.sendKeys "{TAB}{TAB}{TAB}{TAB}" 'VbsCode
WScript.Sleep 500 : WshShell.sendKeys "{DOWN}{DOWN}{DOWN}{DOWN}" 'VbsCode
WScript.Sleep 500 : WshShell.sendKeys "{DOWN}{DOWN}{ENTER}" 'VbsCode
WScript.Sleep 500 : WshShell.sendKeys "{TAB}{TAB}{TAB}{TAB}{W}" 'VbsCode
End Sub 'VbsCode
GPEditOptions 'VbsCode
WScript.Quit 0 'VbsCode
Hope this helps anyone facing similar issue.
There is no need of sending bunch of keys and getting the Group policy editor window title.
Actually every group policy setting has equivalent registry keys. And registry can be edited easily from VBScript. To find the equivalent registry key for the group policy setting:
Download a tool named Process Monitor from SysInternals.
Run it and click Filter > Filter.
Now create two filters like: "Process name" - "is" - "mmc.exe" - then "include" and "Operation" - "is" - "RegSetValue" - then "Include".
Now edit the group policy setting and the registry key will appear in Process monitor.
And Function to edit registry in VBScript:
Function RegSetValue(regkey,value)
Dim WshShell
Set WshShell = CreateObject("Wscript.Shell")
WshShell.RegWrite(regkey,value)
End Function
I made a simple vbs script to kill a process but need to loop it.
Dim oShell : Set oShell = CreateObject("WScript.Shell")
WScript.Sleep 5000
oShell.Run "taskkill /im firefox.exe", , True
loop
Dim oShell : Set oShell = CreateObject("WScript.Shell")
Do
WScript.Sleep 5000
oShell.Run "taskkill /im firefox.exe", , True
loop
Will kill firefox every 5 secs forever.
i need an example script or bat file where by i want to do the following :>
test the telnet connection and ports to 3 different machines and ports at the same time.
the machine is very locked down, so unable to install putty or any other 3rd party apps or have web access.
I just need the script to telnet to the 1st box and then move to the next.
i have tried the script below but it just stops on the 1st box
<job>
<script language="VBScript">
Option Explicit
On Error Resume Next
Dim WshShell
set WshShell=CreateObject("WScript.Shell")
WshShell.run "cmd.exe"
WScript.Sleep 1000
WshShell.SendKeys "telnet x.x.x.x 7005"
WshShell.SendKeys ("{Enter}")
WshShell.SendKeys "exit"
WshShell.SendKeys ("{Enter}")
WshShell.SendKeys "telnet x.x.x.x 8600"
WshShell.SendKeys ("{Enter}")
WshShell.SendKeys "exit"
WshShell.SendKeys ("{Enter}")
WScript.Quit
</script>
</job>
hope someone can shed some light on this.
Many thanks
Marzanur
There are several issues with this script:
You need to seperatate the
Telnet *.*.*.* 7005
Commands with
wscript.sleep 1000
So that the computer has time to connect. Secondly. Telnet opens in a unique command line interface and "exit" is not an accepted by the telnet interface. However, "quit" is used.
So to replace:
Wshshell.sendkeys "exit"
With
Wshshell.sendkeys "quit"
'Wait for close
Wscript.sleep 500
Telnet commands -> http://technet.microsoft.com/en-us/library/c.aspx
WshShell.SendKeys "telnet x.x.x.x 7005"
WshShell.SendKeys "{Enter}"
WshShell.SendKeys "^]"
WshShell.SendKeys "quit{Enter}"
CTRL + ] jumps out of your telnet session and to the terminal console where you can type quit.
I set up a small 3 router network via GNS3. I can connect on it via my pc (telnet) and execute simple cisco commands like show int brief.
Now I found a batch file here that I modified a little to login all 3 routers and execute the show ip int brief command. I have all the info on my screen, but I would like to have it in a .csv file.
I changed the router IP's
R1: 1.1.1.1, R2: 2.2.2.2, R3: 3.3.3.3
This is the batch-file
:: Open a Telnet window
start telnet.exe 1.1.1.1
:: Run the script
cscript showipintbrief.vbs
This is the vbs file (showipintbrief.vbs):
set OBJECT=WScript.CreateObject("WScript.Shell")
WScript.sleep 50
OBJECT.SendKeys "loginR1password{ENTER}"
WScript.sleep 50
OBJECT.SendKeys "enable{ENTER}"
WScript.sleep 50
OBJECT.SendKeys "enableR1password{ENTER}"
WScript.sleep 50
OBJECT.SendKeys "show ip int brief{ENTER}"
WScript.sleep 50
Echo Interface, IP-Address > showipintbrief.csv
OBJECT.SendKeys "telnet 2.2.2.2{ENTER}"
WScript.sleep 50
OBJECT.SendKeys "loginR2password{ENTER}"
WScript.sleep 50
OBJECT.SendKeys "enable{ENTER}"
WScript.sleep 50
OBJECT.SendKeys "enableR2password{ENTER}"
WScript.sleep 50
OBJECT.SendKeys "show ip int brief{ENTER}"
WScript.sleep 50
OBJECT.SendKeys "telnet 3.3.3.3{ENTER}"
WScript.sleep 50
OBJECT.SendKeys "loginR3password{ENTER}"
WScript.sleep 50
OBJECT.SendKeys "enable{ENTER}"
WScript.sleep 50
OBJECT.SendKeys "enableR3password{ENTER}"
WScript.sleep 50
OBJECT.SendKeys "show ip int brief{ENTER}"
WScript.sleep 50
OBJECT.SendKeys "exit{ENTER}"
WScript.sleep 50
OBJECT.SendKeys "exit{ENTER}"
WScript.sleep 50
OBJECT.SendKeys "exit{ENTER}"
For instance Interface, Ip-address, status and protocol should be sent to a .csv file
Anyone can help wiht this please?
Thanks a lot
Try this to log the data and execute it from the cmd prompt, where batchfile.bat is your batch file name.
batchfile.bat >file.log