Skip to main content

Posts

Use SendKeys in PowerShell

Script below will use SendKeys in PowerShell, the old fashioned way.

Script below will open a Notepad and type or send some string to notepad.

It will also open windows calculator and do some calculation.

Here's the script:

#====================================

$wshell = New-Object -ComObject Wscript.Shell

#Call notepad and run it
$wshell.Run("notepad")

#Delay for 1 second
Start-Sleep -m 1000

#Send keys to notepad
$wshell.SendKeys("123 test 456")

#Delay for 2 seconds
Start-Sleep -m 2000

#Run Windows Calculator
$wshell.Run("calc")

#Set the window focus to calculator
#Don't click or press the keyboard or mouse so focus will not be changed
$wshell.appactivate("Calculator")

#sleep again for 1 second
Start-Sleep -m 1000

#Do the calculation by sending keys to calculator
$wshell.SendKeys("5")
$wshell.SendKeys("*")
$wshell.SendKeys("5")
$wshell.SendKeys("=")

#====================================

Cheers..Have fun with PowerShell…

Burn an ISO file in Windows 7 or 8

Use command line to burn an ISO file in Windows.

Windows 7 and Windows 8 comes with an exe file to burn an ISO file via command prompt.

The syntax is quite easy to remember.

Open a command prompt and type:

isoburn /q a: Windows_and_Linux.iso

isoburn /q ISOFilename.to.be.burn

That's it, ISO will be burn to disc.

See picture below if no disc on the drive, when burning an ISO file via command prompt.


Windows export firewall policy

Use netsh in Windows 7 to export firewall policy using command line.

Open an elevated command prompt and type the netshell command below.

netsh advfirewall export d:\myfirewall.txt


If everything works fine it will display "Ok."

It's exported using a filename with ".txt" extension, but the output is not readable using any text editor.

You can save the file to a USB drive as a backup or import the firewall policy to another computer.


To import the exported firewall policy use this command:

netsh advfirewall import d:\myfirewall.txt


Just replace the word export with "import" and specified the path location of the file.

A very simple way to export firewall policies.


If you want to dig further check out Technet link below:

https://technet.microsoft.com/en-us/library/cc770887%28v=ws.10%29.aspx

If you don't like doing it using command line, exporting firewall policy can also be done using GUI.

Open "Windows Firewall with Advance Security" and loo…