These are just random notes and programs that may have incomplete descriptions. Any scripts or programs use at your risk
Tuesday, November 22, 2011
This is an example of a vb.net 2010 console application i wrote to send emails off an open relay.
Imports System.Net.Mail
Module Module1
Sub Main()
'Arguments
Dim inputArgumentEmailto As String = "/emailto="
Dim inputArgumentSubject As String = "/subject="
Dim inputArgumentSMTP As String = "/smtp="
Dim inputArgumentBody As String = "/body="
Dim inputArgumentEmailFrom As String = "/emailfrom="
Dim inputArgumentQuestion As String = "/?"
' Dim inputQuestion As String = ""
Dim inputEmailto As String = ""
Dim inputSubject As String = ""
Dim inputSMTP As String = ""
Dim inputBody As String = ""
Dim inputEmailFrom As String = ""
Dim strTestArgs As Boolean
For Each s As String In My.Application.CommandLineArgs
If s.ToLower.StartsWith(inputArgumentQuestion) Then
' if /? is an argument then post help
Console.WriteLine("Email Application")
Console.WriteLine("Created by Tony Unger 11/22/2011")
Console.WriteLine("Ver. 1.0")
Console.WriteLine("This requires an open relay")
Console.WriteLine("------------------------------")
Console.WriteLine("Parameters")
Console.WriteLine("")
Console.WriteLine("/emailto=")
Console.WriteLine("/subject=")
Console.WriteLine("/smtp=")
Console.WriteLine("/body=")
Console.WriteLine("/emailfrom=")
Console.WriteLine("")
Console.WriteLine("Example:")
Console.WriteLine("/emailto=toTony@asdf.com")
Console.WriteLine("/subject=**Alert")
Console.WriteLine("/smtp=192.168.1.1")
Console.WriteLine("/emailfrom=FromTony@asdf.com")
Console.WriteLine("/body=body")
Console.WriteLine(" ""/body=This is an alert"" ")
Exit Sub
End If
'Sets arg to string values
If s.ToLower.StartsWith(inputArgumentEmailto) Then
inputEmailto = s.Remove(0, inputArgumentEmailto.Length)
End If
If s.ToLower.StartsWith(inputArgumentSubject) Then
inputSubject = s.Remove(0, inputArgumentSubject.Length)
End If
If s.ToLower.StartsWith(inputArgumentSMTP) Then
inputSMTP = s.Remove(0, inputArgumentSMTP.Length)
End If
If s.ToLower.StartsWith(inputArgumentBody) Then
inputBody = s.Remove(0, inputArgumentBody.Length)
End If
If s.ToLower.StartsWith(inputArgumentEmailFrom) Then
inputEmailFrom = s.Remove(0, inputArgumentEmailFrom.Length)
End If
Next
'Checks if all args are there
If inputEmailto = "" Then
Console.WriteLine("/emailto= is required")
strTestArgs = True
End If
If inputSubject = "" Then
Console.WriteLine("/subject= is required")
strTestArgs = True
End If
If inputSMTP = "" Then
Console.WriteLine("/smtp= is required")
strTestArgs = True
End If
If inputBody = "" Then
Console.WriteLine("/body= is required")
strTestArgs = True
End If
If inputEmailFrom = "" Then
Console.WriteLine("/emailfrom= is required")
strTestArgs = True
End If
' If any args are missing exit sub
If strTestArgs = True Then
Exit Sub
End If
EmailtoSupport(inputEmailto, inputSubject, inputSMTP, inputBody, inputEmailFrom)
End Sub
Public Sub EmailtoSupport(inputEmailto As String, inputSubject As String, inputSMTP As String, inputBody As String, inputEmailFrom As String)
Try
Dim Mail As New MailMessage
Mail.Subject = inputSubject
Mail.To.Add(inputEmailto)
Mail.From = New MailAddress(inputEmailFrom)
Mail.Body = inputBody
Dim SMTP As New SmtpClient(inputSMTP)
SMTP.Port = "25"
SMTP.Send(Mail)
Console.WriteLine("Email Sent!")
Catch ex As Exception
If ex.Message.ToString = "Failure sending mail." Then
Console.WriteLine("There was a failure sending the email.")
Console.WriteLine("check your smtp address")
Console.WriteLine("This program will only use port 25")
Else
Console.WriteLine(ex.Message.ToString)
End If
End Try
End Sub
End Module
Monday, November 14, 2011
Batch file to start performance counters on system startup
Requirements:
Create folder on the c: drive
c:\perflogs\
Download
7-Zip
http://www.7-zip.org/download.html
copy 7za.exe to c:\perflogs
open perfmon and create the counters you wish to use
Add each counter name you created to the batch code under
:logmans in this format logman start countername
Create a schedule task that will run the created batch file at system startup
On reboot all csv files will be added to a zip file called performance{date}.zip
Then performance counters will be started.
REM Tony Unger
REM 8/26/2011
REM Initial Release 1.0
REM This batch file that compress all file in the c:\perflog directory to
performance%date:~4,2%%date:~7,2%%date:~10,4%.zip then purges all the old entries
rem then it starts the performance log again
7za.exe a -tzip c:\perflogs\performance%date:~4,2%%date:~7,2%%date:~10,4%.zip c:\perflogs\*.csv
if exist c:\perflogs\performance%date:~4,2%%date:~7,2%%date:~10,4%.zip goto PurgeOldRecords
:Exit
exit
:PurgeOldRecords
del *.blg
del *.csv
goto logmans
:logmans
logman start DiskSpace
logman start Memory
logman start CPU
logman start SQLMemory
go to exit
Create folder on the c: drive
c:\perflogs\
Download
7-Zip
http://www.7-zip.org/download.html
copy 7za.exe to c:\perflogs
open perfmon and create the counters you wish to use
Add each counter name you created to the batch code under
:logmans in this format logman start countername
On reboot all csv files will be added to a zip file called performance{date}.zip
Then performance counters will be started.
REM Tony Unger
REM 8/26/2011
REM Initial Release 1.0
REM This batch file that compress all file in the c:\perflog directory to
performance%date:~4,2%%date:~7,2%%date:~10,4%.zip then purges all the old entries
rem then it starts the performance log again
7za.exe a -tzip c:\perflogs\performance%date:~4,2%%date:~7,2%%date:~10,4%.zip c:\perflogs\*.csv
if exist c:\perflogs\performance%date:~4,2%%date:~7,2%%date:~10,4%.zip goto PurgeOldRecords
:Exit
exit
:PurgeOldRecords
del *.blg
del *.csv
goto logmans
:logmans
logman start DiskSpace
logman start Memory
logman start CPU
logman start SQLMemory
go to exit
Wednesday, November 2, 2011
Windows API Calls Programs
Found from http://www.angelfire.com/poetry/vbpoet/myvb.htm
Convert the letters in a string to all Lower case letters
Private Declare Function CharLower Lib "user32.dll" Alias "CharLowerA" (ByVal lpsz As String) As String
Private Sub Form_Load()
' Convert the string "This is a TEST for LOWER Case Convertion!" into lower-case.
Dim t As String ' target string
t = CharLower("This is a TEST for LOWER Case Convertion!") ' Convert to lower-case
MsgBox t
End
End Sub
Convert the letters in a string to all Upper case letters
Private Declare Function CharUpper Lib "user32.dll" Alias "CharUpperA" (ByVal lpsz As String) As String
Private Sub Form_Load()
' Convert the string "This is a test for upper Case Convertion!" into upper-case.
Dim t As String ' target string
t = CharUpper("This is a test for upper Case Convertion!") ' Convert to upper-case
MsgBox t
End
End Sub
Copy a file
Private Declare Function CopyFile Lib "kernel32.dll" Alias "CopyFileA" (ByVal lpExistingFileName As String, ByVal lpNewFileName As String, ByVal bFailIfExists As Long) As Long
Private Sub Form_Load()
Dim retval As Long ' return value
' copy the file
retval = CopyFile("D:\sample.txt", "D:\example.txt", 1) '1 indicates return value if succeeded
If retval = 0 Then ' failure
MsgBox "Error copying file."
Else ' success
MsgBox "Copy succeeded."
End If
End
End Sub
Move a file
Private Declare Function MoveFile Lib "kernel32.dll" Alias "MoveFileA" (ByVal lpExistingFileName As String, ByVal lpNewFileName As String) As Long
Private Sub Form_Load()
Dim retval As Long ' return value
retval = MoveFile("D:\showagent.txt", "D:\showagent1.txt")
If retval = 0 Then
MsgBox "File not found"
Else
MsgBox "File Move successful"
End If
End
End Sub
Display Shutdown dialog screen
Private Declare Sub ExitWindowsDialog Lib "shell32.dll" Alias "#60" (ByVal hwndOwner As Long)
Private Sub Form_Load()
' Shut Down Windows dialog box.
ExitWindowsDialog 0
End
End Sub
Display the restart or shutdown dialog
Private Declare Function RestartDialog Lib "shell32.dll" Alias "#59" (ByVal hwndOwner As Long, ByVal lpstrReason As String, ByVal uFlags As Long) As Long
Private Sub Form_Load()
'Restart
retval = RestartDialog(Form1.hWnd, "I warn you that ", 2)
'Shutdown
'retval = RestartDialog(Form1.hWnd, "I warn you to Shutdown the system ", 1)
End
End Sub
Display shutdown dialog screen
Private Declare Function SHShutDownDialog Lib "shell32" Alias "#60" (ByVal YourGuess As Long) As Long
Private Sub Form_Load()
SHShutDownDialog 0
End
End Sub
To LOGOFF or SHUTDOWN or REBOOT or FORCE LOGOFF
Private Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long
Private Sub Command1_Click()
'Logoff
ExitWindowsEx 0, 0
'Shutdown
'ExitWindowsEx 1, 0
'Reboot
'ExitWindowsEx 2, 0
'Force Logoff
'ExitWindowsEx 4, 0
End Sub
Flash the Window
Private Declare Function GetActiveWindow Lib "user32.dll" () As Long
Private Declare Function FlashWindow Lib "user32.dll" (ByVal hwnd As Long, ByVal bInvert As Long) As Long
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Sub Command1_Click()
Dim c As Integer
Dim hactive As Long ' handle for the active window
Dim retval As Long ' return value
hactive = GetActiveWindow() ' get the handle of active window
For c = 1 To 20 ' flash ten times
retval = FlashWindow(hactive, 1) 'Change the look of the window
Sleep 500 ' Delay the execution for 1/2 minute
Next c
retval = FlashWindow(hactive, 0) ' Bring the window to normal look
End Sub
Set Computer Name
Private Declare Function SetComputerName Lib "kernel32" Alias "SetComputerNameA" (ByVal lpComputerName As String) As Long
Private Sub Form_Load()
SetComputerName "Karthik"
End
End Sub
Get Computer Name
Private Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Private Sub Form_Load()
Dim a As String * 256
x = GetComputerName(a, 256)
MsgBox Left(a, InStr(a, Chr(0)) - 1)
End
End Sub
Get the System directory of your OS
Private Declare Function GetSystemDirectory Lib "kernel32" Alias "GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
Private Sub Form_Load()
Dim a As String * 256
GetSystemDirectory a, 256
MsgBox Left(a, InStr(a, Chr(0)) - 1)
End
End Sub
Get the Temp directory of your OS
Private Declare Function GetTempPath Lib "kernel32" Alias "GetTempPathA" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long
Private Sub Form_Load()
Dim a As String * 256
GetTempPath 256, a
MsgBox Left(a, InStr(a, Chr(0)) - 1)
End
End Sub
Get the Windows directory of your OS
Private Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
Private Sub Form_Load()
Dim a As String * 256
GetWindowsDirectory a, 256
MsgBox Left(a, InStr(a, Chr(0)) - 1)
End
End Sub
Get your OS information
Private Type OSVERSIONINFO
dwOSVersionInfoSize As Long
dwMajorVersion As Long
dwMinorVersion As Long
dwBuildNumber As Long
dwPlatformId As Long
szCSDVersion As String * 128
End Type
Private Declare Function GetVersionEx Lib "kernel32.dll" Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFO) As Long
Private Sub Form_Load()
Dim os As OSVERSIONINFO ' receives version information
Dim retval As Long ' return value
os.dwOSVersionInfoSize = Len(os) ' set the size of the structure
retval = GetVersionEx(os) ' read Windows's version information
MsgBox "Windows version number:" & os.dwMajorVersion & Chr(Asc(".")) & os.dwMinorVersion
MsgBox "OS Version Info Size = " & os.dwOSVersionInfoSize
MsgBox "BuildNumber = " & os.dwBuildNumber
MsgBox "Platform ID = " & os.dwPlatformId 'Note If ID =0 win 3.x , ID=1 win9x and ID =2 WINNT
MsgBox "CSD Version = " & os.szCSDVersion
End
End Sub
Get the screen resolution
Private Declare Function GetSystemMetrics Lib "user32.dll" (ByVal nIndex As Long) As Long
Const SM_CXSCREEN = 0
Const SM_CYSCREEN = 1
Private Sub Form_Load()
MsgBox "Current Screen Resolution is " & GetSystemMetrics(SM_CXSCREEN) & " x " & GetSystemMetrics(SM_CYSCREEN)
End
End Sub
Add a file to recent documents menu
Private Declare Sub SHAddToRecentDocs Lib "shell32.dll" (ByVal uFlags As Long, ByVal pv As Any)
Private Sub Form_Load()
' add the file D:\VBFinished\myagent.ini to the recent documentsmenu.
SHAddToRecentDocs 2, "D:\VBFinished\myagent.ini"
End
End Sub
Clear the recent documents menu
Private Declare Sub SHAddToRecentDocs Lib "shell32.dll" (ByVal uFlags As Long, ByVal pv As Any)
Private Sub Form_Load()
'Silently Clear the Documents menu entirely.
SHAddToRecentDocs 0, anything
End
End Sub
Clear recylebin without confirmation
Private Declare Function SHEmptyRecycleBin Lib "shell32.dll" Alias "SHEmptyRecycleBinA" (ByVal hwnd As Long, ByVal pszRootPath As String, ByVal dwFlags As Long) As Long
Private Declare Function SHUpdateRecycleBinIcon Lib "shell32.dll" () As Long
Private Sub Form_Load()
' Delete the contents in the Recycle Bin, without confirmation
Dim retval As Long ' return value
retval = SHEmptyRecycleBin(Form1.hwnd, "", 1)
If retval <> 0 Then ' error
retval = SHUpdateRecycleBinIcon()
End If
End
End Sub
To show or hide mouse pointer
Private Declare Function ShowCursor& Lib "user32" (ByVal bShow As Long)
Private Sub Command1_Click()
'To show the cursor, use this:
ShowCursor (1)
'To hide the cursor, use this:
ShowCursor (0)
End Sub
Delay
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Sub Form_Load()
MsgBox "Before Sleep"
Sleep 3000 ' Delay 3 seconds
MsgBox "After Sleep"
End
End Sub
Swap Mouse buttons
Private Declare Function SwapMouseButton Lib "user32" (ByVal bSwap As Long) As Long
Private Sub Command1_Click()
'Swap the mouse buttons
SwapMouseButton 1
End Sub
Private Sub Command2_Click()
'Bring to normal position
SwapMouseButton 0
End Sub
Private Sub Command3_Click()
End
End Sub
Enable or Disable CONTROL + ALT + DELETE
Private Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, ByRef lpvParam As Any, ByVal fuWinIni As Long) As Long
Private Sub Command1_Click()
'Disable Ctrl+Alt+Del,Ctrl+Esc and Alt+Tab
SystemParametersInfo 97, True, waste, 0
End Sub
Private Sub Command2_Click()
'Enable Ctrl+Alt+Del,Ctrl+Esc and Alt+Tab
SystemParametersInfo 97, False, waste, 0
End Sub
Map Network drives or printers
Private Declare Function WNetConnectionDialog Lib "mpr.dll" (ByVal hwnd As Long, ByVal dwType As Long) As Long
Private Sub Command1_Click()
'Map Network Drives
x = WNetConnectionDialog(Form1.hwnd, 1)
End Sub
Private Sub Command2_Click()
'Map Network Printers
x = WNetConnectionDialog(Form1.hwnd, 2)
End Sub
Private Sub Command3_Click()
End
End Sub
Remove mapped network drives or printers
Private Declare Function WNetDisconnectDialog Lib "mpr.dll" (ByVal hwnd As Long, ByVal dwType As Long) As Long
Private Sub Command1_Click()
'Remove mapped Network Drives
x = WNetDisconnectDialog(Form1.hwnd, 1)
End Sub
Private Sub Command2_Click()
'Remove mapped Network Printers
x = WNetDisconnectDialog(Form1.hwnd, 2)
End Sub
Private Sub Command3_Click()
End
End Sub
Get network logged on username
Private Declare Function WNetGetUser Lib "mpr.dll" Alias "WNetGetUserA" (ByVal lpName As String, ByVal lpUserName As String, lpnLength As Long) As Long
Private Sub Form_Load()
Dim b As String * 128
WNetGetUser "", b, 128
MsgBox b
End
End Sub
Writing a string data into WIN.INI
Private Declare Function WriteProfileString Lib "kernel32" Alias "WriteProfileStringA" (ByVal lpszSection As String, ByVal lpszKeyName As String, ByVal lpszString As String) As Long
Private Sub Form_Load()
' Set the "Wallpaper" setting in the [Desktop] section of WIN.INI to C:\Windows\Plus!.bmp.
' WARNING: Use extreme caution when editing the WIN.INI file, because writing bad data to it can create disasterous results to the system!
Dim retval As Long ' return value
' Set the value.
retval = WriteProfileString("Desktop", "Wallpaper", "C:\Windows\Plus!.bmp")
End
End Sub
Get a string data from WIN.INI
Private Declare Function GetProfileString Lib "kernel32" Alias "GetProfileStringA" (ByVal lpAppName As String, ByVal lpKeyName As String, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long) As Long
Private Sub Form_Load()
' Read the value "Wallpaper" from under the [Desktop] section of WIN.INI. If an error occurs, the function will return "Error"
Dim wallpaper As String ' receives string read from WIN.INI
Dim slength As Long ' receives length of string read from WIN.INI
Dim buffer As String * 255
' Read the string from WIN.INI
slength = GetProfileString("Desktop", "Wallpaper", "Error", buffer, 255)
wallpaper = Mid(buffer, 1, InStr(buffer, Chr(0)) - 1) ' extract the returned string from the buffer
If wallpaper = "Error" Then
MsgBox "Could not read information from WIN.INI."
Else
MsgBox "Current Wallpaper is " & wallpaper
End If
End
End Sub
Get a integer data from WIN.INI
Private Declare Function GetProfileInt Lib "kernel32" Alias "GetProfileIntA" (ByVal lpAppName As String, ByVal lpKeyName As String, ByVal nDefault As Long) As Long
Private Sub Form_Load()
' Read the value "WallpaperStyle" under the [Desktop] section of the WIN.INI file. Return -1 if an error occured.
Dim tile As Long ' receives the information read from WIN.INI
' Read the data from WIN.INI
tile = GetProfileInt("Desktop", "TileWallPaper", -1)
If tile = 0 Then
MsgBox "Wallpaper is not tiled."
End If
If tile = 1 Then
MsgBox "Wallpaper is tiled"
End If
End
End Sub
Write a string data to an INI file
Private Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long
Private Sub Form_Load()
' Set the value India to "country" in the [ReleaseSoft] section of G:\myagent.ini .
'Also set the value 14 to "zip" under the same section
Dim retval As Long ' return value
' Set the string value.
retval = WritePrivateProfileString("ReleaseSoft", "country", "India", "G:\myagent.ini")
' Set the numeric value.
retval = WritePrivateProfileString("ReleaseSoft", "zip", "14", "G:\myagent.ini")
End
End Sub
Write a section of data to an INI file
Private Declare Function WritePrivateProfileSection Lib "kernel32" Alias "WritePrivateProfileSectionA" (ByVal lpAppName As String, ByVal lpString As String, ByVal lpFileName As String) As Long
Private Sub Form_Load()
'Write a section in the user defined INI file
x = WritePrivateProfileSection("Karthik", "Grade=Best", "G:\myagent.ini")
'Note : When executing next line the previously written value Grade=best will be erased
x = WritePrivateProfileSection("Very Big ", "email=vb_poet@hotmail.com", "G:\myagent.ini")
End
End Sub
Get an integer data from an INI file
Private Declare Function GetPrivateProfileInt Lib "kernel32" Alias "GetPrivateProfileIntA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal nDefault As Long, ByVal lpFileName As String) As Long
Private Sub Form_Load()
' Read the "Accesscode" value under the "[Sample]" section
' of the INI file G:\myagent.ini
Dim mycode As Long ' receives the value returned from the INI file
mycode = GetPrivateProfileInt("Sample", "AccessCode", -1, "G:\myagent.ini")
' Display the result
If mycode = -1 Then ' failure
MsgBox "Could not read the information from the INI file."
Else
MsgBox "Access Code = " & mycode
End If
End
End Sub
'Note: Values read are not case sensitive
Get a string data from an INI file
Private Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
Private Sub Form_Load()
' Read the "email" value under the [ReleaseSoft] section of
' the INI file G:\myagent.ini.
Dim mymail As String ' receives the value read from the INI file
Dim slength As Long ' receives length of the returned string
mymail = Space(255) ' provide enough room for the function to put the value into the buffer
' Read from the INI file
slength = GetPrivateProfileString("ReleaseSoft", "email", "-1", mymail, 255, "G:\myagent.ini")
mymail = Left(mymail, slength) ' extract the returned string from the buffer
If mymail <> "-1" Then
MsgBox "Mail ID is " & mymail
Else
MsgBox "Data not found"
End If
End
End Sub
Get the length of a string
Private Declare Function lstrlen Lib "kernel32.dll" Alias "lstrlenA" (ByVal lpString As Any) As Long
Private Sub Form_Load()
' Display the length of the string "Mission Impossible"
Dim slength As Long ' receives the length of the string
slength = lstrlen("Mission Impossible") ' find the length of the string
MsgBox "The string 'Mission Impossible' contains " & slength & " characters."
End
End Sub
Copy a string to another variable
Private Declare Function lstrcpy Lib "kernel32.dll" Alias "lstrcpyA" (ByVal lpString1 As Any, ByVal lpString2 As Any) As Long
Private Sub Form_Load()
' Copy the source string to the target string
Dim source As String, target As String ' the two strings
Dim retval As Long ' return value
source = "Mission Impossible" ' the source string to copy
target = Space(Len(source))
retval = lstrcpy(target, source) ' set target to equal source
MsgBox "Source string = " & source
MsgBox "Target string = " & target
End
End Sub
Copy n-1 number of characters from source string to the target string
Private Declare Function lstrcpyn Lib "kernel32.dll" Alias "lstrcpynA" (ByVal lpString1 As Any, ByVal lpString2 As Any, ByVal iMaxLength As Long) As Long
Private Sub Form_Load()
' Copy the specified n-1 number of characters from source string to the target string
Dim source As String, target As String ' the two strings
Dim retval As Long ' return value
source = "Mission Impossible" ' the source string to copy
target = Space(7)
retval = lstrcpyn(target, source, 7)
target = Left(target, Len(target) - 1) ' remove the terminating null character
MsgBox "Source string = " & source
MsgBox "Target string = " & target
End
End Sub
Change Wallpaper Immediately
Private Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, ByVal lpvParam As Any, ByVal fuWinIni As Long) As Long
Const SPI_SETDESKWALLPAPER = 20
Const SPIF_UPDATEINIFILE = 1
Dim pic As String
Private Sub Form_Load()
pic = "C:\windows\clouds.bmp"
SystemParametersInfo SPI_SETDESKWALLPAPER, 0, pic, SPIF_UPDATEINIFILE
End Sub
Play A Wave File
Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long
Private Sub Command1_Click()
Dim a As Long
a = PlaySound("c:\windows\media\tada.wav", 1, 1)
End Sub
Open & Close CDROM Drive Door
Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long
Dim lo As Long
Dim sc As Long
'To open the CD door, use this code:
lo = mciSendString("set CDAudio door open", sc, 127, 0)
'To close the CD door, use this code:
lo = mciSendString("set CDAudio door closed", sc, 127, 0)
Hide / Show Start Button, Desktop and Taskbar
Private Declare Function ShowWindow Lib "user32.dll" (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long
Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function EnableWindow Lib "user32.dll" (ByVal hWnd As Long, ByVal fEnable As Long) As Long
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Public Sub taskBar(Visible As Boolean)
Dim hWnd As Long
hWnd = FindWindow("Shell_TrayWnd", "")
If Visible Then
ShowWindow hWnd, 5
Else
ShowWindow hWnd, 0
End If
End Sub
Public Sub desktop(Visible As Boolean)
Dim hWnd As Long
hWnd = FindWindow("Progman", "Program Manager")
If Visible Then
ShowWindow hWnd, 5
Else
ShowWindow hWnd, 0
End If
End Sub
Public Sub button(Visible As Boolean)
Dim hWnd, dwnd As Long
hWnd = FindWindow("Shell_TrayWnd", "")
dwnd = FindWindowEx(hWnd, 0, "Button", vbNullString)
If Visible Then
ShowWindow dwnd, 5
Else
ShowWindow dwnd, 0
End If
End Sub
'Show the stuff checked
Private Sub Command1_Click()
If Check1.Value = 1 Then
taskBar (True)
End If
If Check2.Value = 1 Then
desktop (True)
End If
If Check3.Value = 1 Then
button (True)
End If
End Sub
'Hide the stuff checked
Private Sub Command2_Click()
If Check1.Value = 1 Then
taskBar (False)
End If
If Check2.Value = 1 Then
desktop (False)
End If
If Check3.Value = 1 Then
button (False)
End If
End Sub
Check windows boot manner
Private Declare Function GetSystemMetrics Lib "user32.dll" (ByVal nIndex As Long) As Long
Private Sub Form_Load()
'Check booted manner
x = GetSystemMetrics(67)
Select Case x
Case 0
MsgBox "Normal Boot"
Case 1
MsgBox "Safe mode"
Case 2
MsgBox "Safe mode with Network"
End Select
End
End Sub
Get drive type
Private Declare Function GetDriveType Lib "kernel32.dll" Alias "GetDriveTypeA" (ByVal nDrive As String) As Long
Private Const DRIVE_UNKNOWN = 0
Private Const DRIVE_DOES_NOT_EXIST = 1
Private Const DRIVE_REMOVABLE = 2
Private Const DRIVE_FIXED = 3
Private Const DRIVE_REMOTE = 4
Private Const DRIVE_CDROM = 5
Private Const DRIVE_RAMDISK = 6
Private Sub Form_Load()
Select Case GetDriveType("C:\")
Case DRIVE_UNKNOWN
MsgBox "Type Unknown", vbExclamation
Case DRIVE_DOES_NOT_EXIST
MsgBox "Type Unknown", vbCritical
Case DRIVE_REMOVABLE
MsgBox "The disk can be removed from the drive", vbInformation
Case DRIVE_FIXED
MsgBox "The disk can not be removed from the drive", vbInformation
Case DRIVE_REMOTE
MsgBox "The drive is a remote (network) drive", vbInformation
Case DRIVE_CDROM
MsgBox "The drive is a CD-ROM drive", vbInformation
Case DRIVE_RAMDISK
MsgBox "The drive is a RAM disk", vbInformation
End Select
End
End Sub
Get windows about box
Private Declare Function ShellAbout Lib "shell32.dll" Alias "ShellAboutA" (ByVal hWnd As Long, ByVal szApp As String, ByVal szOtherStuff As String, ByVal hIcon As Long) As Long
Private Sub Form_Load()
ShellAbout hWnd, "Karthikeyan ", "For More Details contact KARTHIKEYAN", hIcon
End
End Sub
Get the time elapsed after system boot
Private Declare Function GetTickCount Lib "kernel32.dll" () As Long
Private Sub Form_Load()
Dim m As Long
Dim s As Long
m = CStr(GetTickCount) / 1000 / 60
Label1.Caption = "You have been using this computer for past " & m & " minutes "
End Sub
Show / Hide your application in tasklist (No API)
Private Sub Option1_Click()
App.TaskVisible = True
End Sub
Private Sub Option2_Click()
App.TaskVisible = False
End Sub
Thursday, October 27, 2011
Runas program for touch screens
This has been updated :
http://www.tonyunger.com/2012/01/runas-touch-screen-application-purpose.html
Purpose: Touch screen application to run applications as a different user. It also dynamic creates button based on what it reads from a text file. I have added many changes to this application and will post a new version soon this week.
http://www.tonyunger.com/2012/01/runas-touch-screen-application-purpose.html
Purpose: Touch screen application to run applications as a different user. It also dynamic creates button based on what it reads from a text file. I have added many changes to this application and will post a new version soon this week.
Monday, October 24, 2011
Run explorer using the Runas Command
Little batch file i made to run explorer using the runas command.
It adds a registry key to the current user hive that is being used to to run explorer as a different user.
@Echo Off
Echo Importing Key
reg add "HKCU\software\microsoft\windows\currentversion\explorer\advanced" /v SeparateProcess /t REG_DWORD /d 00000001 /f
Echo Reg Key imported
Echo Starting Explorer
explorer /e
Echo Closing Explorer
reg add "HKCU\software\microsoft\windows\currentversion\explorer\advanced" /v SeparateProcess /t REG_DWORD /d 00000000 /f
exit
It adds a registry key to the current user hive that is being used to to run explorer as a different user.
@Echo Off
Echo Importing Key
reg add "HKCU\software\microsoft\windows\currentversion\explorer\advanced" /v SeparateProcess /t REG_DWORD /d 00000001 /f
Echo Reg Key imported
Echo Starting Explorer
explorer /e
Echo Closing Explorer
reg add "HKCU\software\microsoft\windows\currentversion\explorer\advanced" /v SeparateProcess /t REG_DWORD /d 00000000 /f
exit
Tuesday, September 20, 2011
bit for bit copy of usb flash drive free utiltiy
Found this free utility to create a bit by bit copy of a flash drive
http://www.osforensics.com/tools/write-usb-images.html
ImageUSB is a free utility which lets you write an image concurrently to multiple USB Flash Drives. Capable of creating exact bit-level copies of USB Flash Drive (UFDs), ImageUSB is an extremely effective tool for the mass duplication of UFDs. ImageUSB also supports writing of an ISO file byte by byte directly to an USB drive, useful in conversion of bootable CD/DVD iso to a bootable USB drive. ImageUSB can also be used to install OSFClone to a USB Drive for use with PassMark OSForensics™.
Download Link
http://www.osforensics.com/downloads/imageusb.zip
Download link if site is down
http://dl.dropbox.com/u/24077962/imageusb.zip
Friday, September 16, 2011
Shell ipconfig the lazy way Visual Basic 2010
Shell("cmd /c ipconfig /all | findstr ""IPv4 Subnet Gateway"" > c:\support\ipconfig.txt", AppWinStyle.Hide, True)
lblIPConfig.Text = My.Computer.FileSystem.ReadAllText("c:\support\ipconfig.txt")
Tuesday, September 6, 2011
Managing AD objects
3 Ways to Move AD Objects
1. Open ADUC and drag and drop object
2. Context Menu - right click
3. DSMove - Command line
Example
To move user tunger from the users container to the sales users ou under corp users ou here is the command
dsmove "cn=tunger,cn=users,dc=tonyunger,dc=com" -newparent "ou=sales users,ou=corp users,dc=tonyunger,dc=com"
3 Ways to Delete Objects
1. Highlight object and hit delete button on keyboard
2. context Menu - right click and choose delete
3. DSRM - command line
Delete User:
DSRM "cn=tunger,cn=users,dc=tonyunger,dc=com"
Delete OU:
Remove an ou named sales users and all objects under the ou
DSRM -subtree - nopromp -c "ou=sales users,ou=corp users,dc=tonyunger,dc=com"
To remove all objects under an OU named sales, but leave the ou intact
DSRM - subtree -exclude -noprompt -c "ou=sales users,ou=corp users,dc=tonyunger,dc=com"
Add a user
dsadd user "cn=tunger,cn=users,dc=tonyunger,dc=com" -fn Tony -ln Unger -pwd 1234 -mustchpwd yes
1. Open ADUC and drag and drop object
2. Context Menu - right click
3. DSMove - Command line
Example
To move user tunger from the users container to the sales users ou under corp users ou here is the command
dsmove "cn=tunger,cn=users,dc=tonyunger,dc=com" -newparent "ou=sales users,ou=corp users,dc=tonyunger,dc=com"
3 Ways to Delete Objects
1. Highlight object and hit delete button on keyboard
2. context Menu - right click and choose delete
3. DSRM - command line
Delete User:
DSRM "cn=tunger,cn=users,dc=tonyunger,dc=com"
Delete OU:
Remove an ou named sales users and all objects under the ou
DSRM -subtree - nopromp -c "ou=sales users,ou=corp users,dc=tonyunger,dc=com"
To remove all objects under an OU named sales, but leave the ou intact
DSRM - subtree -exclude -noprompt -c "ou=sales users,ou=corp users,dc=tonyunger,dc=com"
Add a user
dsadd user "cn=tunger,cn=users,dc=tonyunger,dc=com" -fn Tony -ln Unger -pwd 1234 -mustchpwd yes
Shadow Groups
http://trycatch.be/blogs/roggenk/archive/2007/07/18/active-directory-domain-services-fine-grained-password-policies.aspx
A shadow group is a global security group that is logically mapped to an OU to enforce a fine-grained password policy. You add users of the OU as members of the newly created shadow group and then apply the fine-grained password policy to this shadow group. You can create additional shadow groups for other OUs as needed
More information:
http://technet.microsoft.com/en-us/library/cc770394(WS.10).aspx
A shadow group is a global security group that is logically mapped to an OU to enforce a fine-grained password policy. You add users of the OU as members of the newly created shadow group and then apply the fine-grained password policy to this shadow group. You can create additional shadow groups for other OUs as needed
More information:
http://technet.microsoft.com/en-us/library/cc770394(WS.10).aspx
Monday, September 5, 2011
Active Directory Service command-line tools
High overview
dsadd adding objects.
dsget displaying objects.
dsmod modifying objects.
dsmove moving objects.
dsquery finding objects matching search criteria.
dsrm deleting objects.
dsadd adding objects.
dsget displaying objects.
dsmod modifying objects.
dsmove moving objects.
dsquery finding objects matching search criteria.
dsrm deleting objects.
Friday, September 2, 2011
From http://www.symantec.com/connect/articles/readyfsmo-roles-active-directory-windows-2008-server
Flexibility Schema Operations Master FSOP
1. Forest Roles
Schema Master - As name suggests, the changes that are made while creation of any object in AD or changes in attributes will be made by single domain controller and then it will be replicated to another domain controllers that are present in your environment. There is no corruption of AD schema if all the domain controllers try to make changes. This is one of the very important roles in FSMO roles infrastructure.
Domain Naming Master - This role is not used very often, only when you add/remove any domain controllers. This role ensures that there is a unique name of domain controllers in environment.
2. Domain Roles
Infrastructure Master - This role checks domain for changes to any objects. If any changes are found then it will replicate to another domain controller.
RID Master - This role is responsible for making sure each security principle has a different identifier.
PDC emulator - This role is responsible for Account policies such as client password changes and time synchronization in the domain
Where these roles are configured?
Domain wide roles are configured in Active Directory users and computers. Right click and select domain and here option is operations master.
Forest roles Domain Naming master is configured in active directory domain and trust right click and select operations master. It will let you know the roles.
(c)Forest roles Schema Master is not accessible from any tool as they want to prevent this. Editing schema can create serious problem in active directory environment. To gain access you need to create snap-in and register dll file by regsvr32 schmmgmt.dll.
Seizing of Roles
In case of failures of any server you need to seize the roles. This is how it can be done:
For Schema Master:
Go to cmd prompt and type ntdsutil
Ntdsutil: prompt type roles to enter fsmo maintenance.
Fsmo maintenance: prompt type connections to enter server connections.
Server connections: prompt, type connect to server domain controller, where
Domain controller is the name of the domain controller to which you are going to transfer the role
Server connections: prompt, type quit to enter fsmo maintenance.
Fsmo maintenance: prompt, type seize schema master.
After you have Seize the role, type quit to exit NTDSUtil.
For Domain Naming Master:
Go to cmd prompt and type ntdsutil
Ntdsutil: prompt type roles to enter fsmo maintenance.
Fsmo maintenance: prompt type connections to enter server connections.
Server connections: prompt, type connect to server domain controller, where
Domain controller is the name of the domain controller to which you are going to transfer the role
Server connections: prompt, type quit to enter fsmo maintenance.
Fsmo maintenance: prompt, type seize domain naming master.
After you have Seize the role, type quit to exit NTDSUtil.
For Infrastructure Master Role:
Go to cmd prompt and type ntdsutil
Ntdsutil: prompt type roles to enter fsmo maintenance.
Fsmo maintenance: prompt type connections to enter server connections.
Server connections: prompt, type connect to server domain controller, where
Domain controller is the name of the domain controller to which you are going to transfer the role
Server connections: prompt, type quit to enter fsmo maintenance.
Fsmo maintenance: prompt, type seize infrastructure master.
After you have Seize the role, type quit to exit NTDSUtil.
For RID Master Role:
Go to cmd prompt and type ntdsutil
Ntdsutil: prompt type roles to enter fsmo maintenance.
Fsmo maintenance: prompt type connections to enter server connections.
Server connections: prompt, type connect to server domain controller, where
Domain controller is the name of the domain controller to which you are going to transfer the role
Server connections: prompt, type quit to enter fsmo maintenance.
Fsmo maintenance: prompt, type seize RID master.
After you have Seize the role, type quit to exit NTDSUtil.
For PDC Emulator Role:
Go to cmd prompt and type ntdsutil
Ntdsutil: prompt type roles to enter fsmo maintenance.
Fsmo maintenance: prompt type connections to enter server connections.
Server connections: prompt, type connect to server domain controller, where
Domain controller is the name of the domain controller to which you are going to transfer the role
Server connections: prompt, type quit to enter fsmo maintenance.
Fsmo maintenance: prompt, type seize PDC.
After you have Seize the role, type quit to exit NTDSUtil.
Flexibility Schema Operations Master FSOP
1. Forest Roles
Schema Master - As name suggests, the changes that are made while creation of any object in AD or changes in attributes will be made by single domain controller and then it will be replicated to another domain controllers that are present in your environment. There is no corruption of AD schema if all the domain controllers try to make changes. This is one of the very important roles in FSMO roles infrastructure.
Domain Naming Master - This role is not used very often, only when you add/remove any domain controllers. This role ensures that there is a unique name of domain controllers in environment.
2. Domain Roles
Infrastructure Master - This role checks domain for changes to any objects. If any changes are found then it will replicate to another domain controller.
RID Master - This role is responsible for making sure each security principle has a different identifier.
PDC emulator - This role is responsible for Account policies such as client password changes and time synchronization in the domain
Where these roles are configured?
Domain wide roles are configured in Active Directory users and computers. Right click and select domain and here option is operations master.
Forest roles Domain Naming master is configured in active directory domain and trust right click and select operations master. It will let you know the roles.
(c)Forest roles Schema Master is not accessible from any tool as they want to prevent this. Editing schema can create serious problem in active directory environment. To gain access you need to create snap-in and register dll file by regsvr32 schmmgmt.dll.
Seizing of Roles
In case of failures of any server you need to seize the roles. This is how it can be done:
For Schema Master:
Go to cmd prompt and type ntdsutil
Ntdsutil: prompt type roles to enter fsmo maintenance.
Fsmo maintenance: prompt type connections to enter server connections.
Server connections: prompt, type connect to server domain controller, where
Domain controller is the name of the domain controller to which you are going to transfer the role
Server connections: prompt, type quit to enter fsmo maintenance.
Fsmo maintenance: prompt, type seize schema master.
After you have Seize the role, type quit to exit NTDSUtil.
For Domain Naming Master:
Go to cmd prompt and type ntdsutil
Ntdsutil: prompt type roles to enter fsmo maintenance.
Fsmo maintenance: prompt type connections to enter server connections.
Server connections: prompt, type connect to server domain controller, where
Domain controller is the name of the domain controller to which you are going to transfer the role
Server connections: prompt, type quit to enter fsmo maintenance.
Fsmo maintenance: prompt, type seize domain naming master.
After you have Seize the role, type quit to exit NTDSUtil.
For Infrastructure Master Role:
Go to cmd prompt and type ntdsutil
Ntdsutil: prompt type roles to enter fsmo maintenance.
Fsmo maintenance: prompt type connections to enter server connections.
Server connections: prompt, type connect to server domain controller, where
Domain controller is the name of the domain controller to which you are going to transfer the role
Server connections: prompt, type quit to enter fsmo maintenance.
Fsmo maintenance: prompt, type seize infrastructure master.
After you have Seize the role, type quit to exit NTDSUtil.
For RID Master Role:
Go to cmd prompt and type ntdsutil
Ntdsutil: prompt type roles to enter fsmo maintenance.
Fsmo maintenance: prompt type connections to enter server connections.
Server connections: prompt, type connect to server domain controller, where
Domain controller is the name of the domain controller to which you are going to transfer the role
Server connections: prompt, type quit to enter fsmo maintenance.
Fsmo maintenance: prompt, type seize RID master.
After you have Seize the role, type quit to exit NTDSUtil.
For PDC Emulator Role:
Go to cmd prompt and type ntdsutil
Ntdsutil: prompt type roles to enter fsmo maintenance.
Fsmo maintenance: prompt type connections to enter server connections.
Server connections: prompt, type connect to server domain controller, where
Domain controller is the name of the domain controller to which you are going to transfer the role
Server connections: prompt, type quit to enter fsmo maintenance.
Fsmo maintenance: prompt, type seize PDC.
After you have Seize the role, type quit to exit NTDSUtil.
Thursday, September 1, 2011
Lan Wan Speed Test Iperf
Iperf is a tool i use to determine tcp or udf performance on a network.
The following commands are to be ran on the client(machine connecting from) and servers(Machine connecting to)
Client:
iperf.exe -c 192.168.1.51
Server:
iperf.exe -s
Iperf is opensource.
Download links
Linux
http://code.google.com/p/iperf/
http://sourceforge.net/projects/iperf/
Windows
https://nocweboldcst.ucf.edu/files/iperf.exe - old
http://www.mayoxide.com/iperf/ - newer build fork.
The following commands are to be ran on the client(machine connecting from) and servers(Machine connecting to)
Client:
iperf.exe -c 192.168.1.51
Server:
iperf.exe -s
Iperf is opensource.
Download links
Linux
http://code.google.com/p/iperf/
http://sourceforge.net/projects/iperf/
Windows
https://nocweboldcst.ucf.edu/files/iperf.exe - old
http://www.mayoxide.com/iperf/ - newer build fork.
Friday, August 26, 2011
using logman to start monitoring counters in perfmon
Create a batch file
create a schedule task to run that batch file at system start up
http://technet.microsoft.com/en-us/library/cc755366(WS.10).aspx
To start daily collections with sample intervals, account names and passwords, type:
Logman start daily_perf_log -s \\%computer_name% -u admin "adminpassword"
To start manual data collections, type:
Logman start daily_perf_log
To stop data collections, type:
Logman stop daily_perf_log
To delete data collections, type:
Logman delete daily_perf_log
To display the status of collection queries, type the following commands:
logman start test
create a schedule task to run that batch file at system start up
http://technet.microsoft.com/en-us/library/cc755366(WS.10).aspx
To start daily collections with sample intervals, account names and passwords, type:
Logman start daily_perf_log -s \\%computer_name% -u admin "adminpassword"
To start manual data collections, type:
Logman start daily_perf_log
To stop data collections, type:
Logman stop daily_perf_log
To delete data collections, type:
Logman delete daily_perf_log
To display the status of collection queries, type the following commands:
Performance log
http://technet.microsoft.com/en-us/library/cc737657(WS.10).aspx
Monitoring performance from the command line
Updated: January 21, 2005
Applies To: Windows Server 2003, Windows Server 2003 R2, Windows Server 2003 with SP1, Windows Server 2003 with SP2
Monitoring performance from the command line
In addition to using the Performance graphical interface, you can use the following command line utilities:
Logman manages and schedules performance counter and event trace log collections on local and remote systems.
Perfmon allows you to open a Performance console configured with the System Monitor ActiveX control and Performance Logs and Alerts Service.
Relog extracts performance counters from performance counter logs into other formats, such as text file (tab delimited), text file (comma delimited), binary-BIN, or SQL.
Tracerpt processes event trace logs or real-time data from instrumented event trace providers and allows you to generate trace analysis reports and CSV (comma-delimited) files for the events generated.
Typeperf writes performance counter data to the command window, or to a supported log file format.
Lodctr registers new Performance counter names and Explain text for a service or device driver, and saves and restores counter settings and Explain text.
Unlodctr removes Performance counter names and Explain text for a service or device driver from the system registry.
For more information about incorporating these Performance commands into your Windows Management Instrumentation (WMI), see "Part One: Operating System Performance" in the System Performance and Troubleshooting Guide, available at the Microsoft Windows Resource Kits Web site.
For information about other command-line utilities, see Command-line reference. For more information about manageability, see Management Strategies and Tools.
Monitoring performance from the command line
Updated: January 21, 2005
Applies To: Windows Server 2003, Windows Server 2003 R2, Windows Server 2003 with SP1, Windows Server 2003 with SP2
Monitoring performance from the command line
In addition to using the Performance graphical interface, you can use the following command line utilities:
Logman manages and schedules performance counter and event trace log collections on local and remote systems.
Perfmon allows you to open a Performance console configured with the System Monitor ActiveX control and Performance Logs and Alerts Service.
Relog extracts performance counters from performance counter logs into other formats, such as text file (tab delimited), text file (comma delimited), binary-BIN, or SQL.
Tracerpt processes event trace logs or real-time data from instrumented event trace providers and allows you to generate trace analysis reports and CSV (comma-delimited) files for the events generated.
Typeperf writes performance counter data to the command window, or to a supported log file format.
Lodctr registers new Performance counter names and Explain text for a service or device driver, and saves and restores counter settings and Explain text.
Unlodctr removes Performance counter names and Explain text for a service or device driver from the system registry.
For more information about incorporating these Performance commands into your Windows Management Instrumentation (WMI), see "Part One: Operating System Performance" in the System Performance and Troubleshooting Guide, available at the Microsoft Windows Resource Kits Web site.
For information about other command-line utilities, see Command-line reference. For more information about manageability, see Management Strategies and Tools.
Monday, August 15, 2011
Tuesday, July 12, 2011
ssh snapshot netapp
Little script i pieced together to create a snapshot via batch file
Requirement
plink just google for putty ssh
Requirement
plink just google for putty ssh
@echo off
echo Note:
echo
echo This batch file will create a snapshot of volumes
echo ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
echo º º
echo ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹
echo º Created by Tony Unger 6/10/2011 º
echo º V1.0 Initial Release º
echo ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ
echo Enter Username:
set /p UserName=
echo Enter Password:
set /p PassWord=
rem ************************* boot_udfdax64db ******************************************************************************************
echo Creating boot_udfdax64db
REM boot_udfdax64db Snapshot
rem creates command to run
echo snap create boot_udfdax64db WedsSnapshot%date:~4,2%%date:~7,2%%date:~10,4%> commands\boot_udfdax64db.txt
rem use plink to ssh tunnel to netapp box and force snapshot
"exe\plink.exe" -ssh -pw %PassWord% -noagent -m commands/boot_udfdax64db.txt %UserName%@172.16.1.1
echo Creating app_udfdax64db
REM app_udfdax64db Snapshot
rem creates command to run
echo snap create app_udfdax64db WedsSnapshot%date:~4,2%%date:~7,2%%date:~10,4%> commands\app_udfdax64db.txt
rem use plink to ssh tunnel to netapp box and force snapshot
"exe\plink.exe" -ssh -pw %PassWord% -noagent -m commands/app_udfdax64db.txt %UserName%@172.16.1.1
rem end
echo Snapshots have completed!
echo Checking if snapshots where configured logs
rem looks to see if snapshot was created on filer
findstr /i "WedsSnapshot%date:~4,2%%date:~7,2%%date:~10,4%" "log\SnapShot_app_udfdax64db.txt"> NUL
if %ERRORLEVEL% EQU 0 (
@echo
app_server snapshot found!
) else (
@echo Error: app_server NOT snapshot found
)
pause
Subscribe to:
Posts (Atom)
-
Running solidcore you may run into a problem where you have to disable it with out using epo or the local CLI Here are the steps. ...
-
Wrote this to get certificate expiration information for certificates that expired 5 days ago to ones that expire in 90 days. Wrap an invoke...
-
List Certificate Templates function get-CertificateTemplates { [ CmdletBinding ()] Param ( [ Parameter ( Mandatory = $True, Va...