Create an Internet shortcut

To create a shortcut to an url you can do as follows

set oUrlLink = WshShell.CreateShortcut(strDesktop & "\Microsoft Web Site.url")
oUrlLink.TargetPath = "http://www.yahoo.com"
oUrlLink.Save

Create a Desktop shortcut using WSH

If you want to create a shortcut programatically use the code below. Found somewhere on net

'Create a Desktop ShortCut
set WshShell = WScript.CreateObject("WScript.Shell")
strDesktop = WshShell.SpecialFolders("Desktop")
set oShellLink = WshShell.CreateShortcut(strDesktop & "\Shortcut To Notepad.lnk")
oShellLink.TargetPath = "Notepad.exe" 'WScript.ScriptFullName
oShellLink.WindowStyle = 1
oShellLink.Hotkey = "CTRL+SHIFT+N"
oShellLink.IconLocation = "notepad.exe, 0"
oShellLink.Description = "Shortcut To Notepad."
oShellLink.WorkingDirectory = strDesktop
oShellLink.Save

Get the name of the host/ computer


Set WshNetwork = WScript.CreateObject("WScript.Network")
WScript.Echo "Domain = " & WshNetwork.UserDomain
WScript.Echo "Computer Name = " & WshNetwork.ComputerName
WScript.Echo "User Name = " & WshNetwork.UserName

Read a Text File and print line by line


Option Explicit
Dim gpsFile
Dim gpsFileLines
Dim eGpsLine

Dim oFSO : Set oFSO = CreateObject("Scripting.FileSystemObject")
Dim oWS : Set oWS = CreateObject("WScript.Shell")
gpsFile = "c:\yourtextfile.txt"

With oFSO.GetFile(gpsFile)
'Get all Lines
gpsFileLines = Split(.OpenAsTextStream(1, 0).Read(.Size), vbcrlf)
End With

For Each eGpsLine in gpsFileLines
'Print all lines on by one
Wscript.Echo eGpsLine & vbcrlf
Next
Wscript.Quit

Get Processor and OS info

We can get the Processor and OS info like this using the Environment method

Set WshShell = WScript.CreateObject(“WScript.Shell”)
Set WshSysEnv = WshShell.Environment(“SYSTEM”)
WScript.Echo “NUMBER OF PROCESSORS : ” & WshSysEnv(“NUMBER_OF_PROCESSORS”)
WScript.Echo “PROCESSOR ARCHITECTURE : ” & WshSysEnv(“PROCESSOR_ARCHITECTURE”)
WScript.Echo “PROCESSOR IDENTIFIER : ” & WshSysEnv(“PROCESSOR_IDENTIFIER”)
WScript.Echo “OS : ” & WshSysEnv(“OS”)

Get Windows Environment Info

To get the Environment info like Compsec, PAth, pathext windows folder and temporary folder location we can do like this


Set WshShell = WScript.CreateObject("WScript.Shell")
Set WshSysEnv = WshShell.Environment("SYSTEM")
WScript.Echo "COMSPEC (Executable file for the command prompt ) : " &_
 WshSysEnv("COMSPEC")

WScript.Echo "PATH : " & WshSysEnv("PATH")
WScript.Echo "PATHEXT : " & WshSysEnv("PATHEXT")

WScript.Echo "WINDIR : " & WshSysEnv("WINDIR")
WScript.Echo "TEMP : " & WshSysEnv("TEMP")

SQLite GUI

SQLite GUI is a simple user Interface for SQLite dB. You can create / open a dB and also can create, delete and update tables in the database. All the tables in a database are shown in the DataGridView .
Data Types including BLOB are supported.

Dependencies
Add the reference SQLite.Net.dll to the project and use the namespace Finisar.SQLite to work with SQLite.

Finisar.SQLite

Finisar.SQLite is an ADO.NET Data Provider for accessing SQLite-Databases using the .NET-Framework. In SQLite a complete database is stored in a single disk file. SQLite is zero-configuration – no setup or administration needed. SQLite itself is “a small C library that implements a self-contained, embeddable, zero-configuration SQL database engine” (quoted from the sqlite.org Website). The Finisar.SQLite Data Provider is an easy way to use the SQLite-Database in .net Languages like C# and VB.net.

Screenshot
sqliteGui Screenshot

Sample Code

try
{
//Connection string
string connString = String.Format(“Data Source={0};New=False;Version=3”, DB_NAME);

//Connecting database
SQLiteConnection sqlconn = new SQLiteConnection(connString);

//Open the connection
sqlconn.Open();

//Query
string CommandText = “Select name from sqlite_master;”;

//SQLiteDataAdapter to fill the DataSet
SQLiteDataAdapter dataAdapter = new SQLiteDataAdapter(CommandText, sqlconn);
dataAdapter.Fill(ds);

//Get the collection of rows from the DataSet
DataRowCollection dataRowCol = ds.Tables[0].Rows;

//Add the tables available in the DB to the combo box
foreach (DataRow dr in dataRowCol)
{
tablecombobox.Items.Add(dr[“name”]);
}

//Close the Connection
sqlconn.Close();

}
catch (SQLiteException sqlex)
{
MessageBox.Show(sqlex.Message);
}

To Do/Known Issues

Update cannnot be performed on table without primary key.
The SelectCommand must also return at least one primary key or unique column. If none are present, an InvalidOperation exception is generated, and the commands are not generated.
The alternative way is create select, insert and update command for that particular table. Refer MSDN .It will be available in the next version of SQLite GUI.

Download Code

Published in CodeProject.com on March 10, 2007