Archive

Posts Tagged ‘Windows’

Download File with a PowerShell One-Liner

December 11th, 2011 No comments

I was recently trying to automate some scripts on a linux box and I wanted to know if it was as simple to download a file in PowerShell as it is in linux: wget http://example.com/file.jpg

Well as it turned out, it wasn’t, but it wasn’t that difficult either. What we needed was too use the System.Net.WebClient class. There’s one thing to note, in PowerShell you can’t use a ~ (tilde) to reference your home directly, that is to say, you can’t download a file to ~\Desktop you will need to specify the full path, in my case C:\Users\Brangle\Desktop. Read more…

Make PowerShell Talk / Speak

December 9th, 2011 No comments

Have you ever run a long PowerShell script, minimized it, only to realize much later that an error caused it to stop? Rather than just using a color syntax red to display the error,  I wanted to hear it so I could switch back to the PowerShell window and see the error.

So how easy is it to make PowerShell speak? It’s almost identical to the .NET code I have in VB.net and C# on Make Your Computer Talk with VB.NET Application (and Source Code) using the SAPI.SpVoice class. Read more…

How To Use the OpenFileDialog Box in VB.NET

September 7th, 2009 No comments

Using the OpenFileDialog box wasn’t as intuitive as I initially expected, I was thinking I could just drag it out onto my form as a button and place it right where I wanted to. But when I clicked on it from toolbox it just went into the bottom frame of my application, but not on my form like I was hoping for. Below I is an example of a dynamically (aka created at run) created OpenFileDialog. Because it’s dynamically created when don’t have to drag it out to form, it’s created by the code, not from the GUI. Read more…

Categories: VB.NET Tags: , ,

How to Cut/Copy/Paste into the Clipboard using VB.NET

August 30th, 2009 3 comments

In this example, I’ll show you how to cut, copy, paste and clear text in the clipboard. Cutting and copying text is really straight forward, pasting text requires just a little bit of checking. For example, we want to check to see what the clipboard contains before we try and do something like pasting an image into a text box. Read more…

Categories: VB.NET Tags: , , ,

Make Your Computer Talk with VB.NET Application (and Source Code)

August 29th, 2009 No comments

I was playing around with COM objects in Windows and discovered that I could access the SAPI.SpVoice interface and make Microsoft Windows talk to me. Well needless to say I had to rush and develop and application to do just that. I uploaded a simple applicaton which will just say whatever you type in as an argument. For example SpeakToMeConsole.exe Hello World will make your computer speak the words “Hello World.” The part that really amazes me is that the guts of this program is only 2 lines long, and it can even that can reduced down to 1 line if we create an anonymous instance of SAPI.SpVoice object. Read more…

Categories: VB.NET Tags: , , , , ,

How to Shutdown, Restart, Log off your computer with VB.NET or C#

August 27th, 2009 3 comments

This is extremely easy using VB.NET or C# (pronounced C sharp) and the built in windows EXE file shutdown.exe. To shutdown, restart, or log off your computer is as simple as entering 1 line into your program, it just so happens that the 1 line is identical whether you’re using VB.NET or C#. Read more…

How to Create Message Box Pop Ups in VB.NET

August 26th, 2009 No comments

Creating different types of messages boxes in Visual Basic is a simple one line statement. I’m going to run through how to create several different types of message boxes in this tutorial, including OK Only, OK/Cancel, Abort/Retry/Ignore, and a Critical message box. Read more…

Categories: VB.NET Tags: , , ,

Combine or Join Two Text Files Using PowerShell

August 26th, 2009 2 comments

Merging files together, or to a seperate file, is a snap with PowerShell using the Get-Content cmdlet. If you’ve never used the Add-Content cmdlet, I would suggest first reading my other article Append Text to a File Using Add-Content. The first thing we need to do is identify our two files, in my case I’ll be using file1.log and file2.log. In the first example, I append all the text of file2.log into the end of file1.log. In the second example, I’ll create a completely new file and dump the contents of both the files into the newly created file. In the last example, I’ll add the current date to the filename of a completly new log file. Read more…

Add or Map a Custom Hostnames to IP Address without a DNS Server

August 25th, 2009 No comments

There’s been several times where I had an Apache server running locally on my computer as a development (or dev) server. Now if this is on my home network, or if your system administrator won’t give you your own custom host name then you have to go the DIY (do it yourself) route. But, often times, I have to hard code host names, or I need several different websites hosted on my personal machine. Well that’s where the hosts file comes into play. Read more…

Retrieve File Permissions using Get-Acl with PowerShell

August 24th, 2009 No comments

Retrieving the owner and permissions of a file, folders and even registry keys is a breeze with PowerShell’s Get-Acl cmdlet. Let’s try checking to see who has access to to the C:\Documents and Settings\Administrator folder. Read more…