19 Eylül 2014 Cuma
17 Eylül 2014 Çarşamba
Yedekleme ve Geri Yükleme
*************backup*********************** Robocopy "C:\documents and settings\%username%\application data\microsoft\signatures" h:\backup\%username%\signatures *.* /e Robocopy "c:\documents and settings\%username%\application data\microsoft\Outlook" h:\backup\%username%\NK2 *.nk2 Robocopy "C:\documents and settings\%username%\Desktop" h:\backup\%username%\Desktop *.* /e Robocopy "C:\documents and settings\%username%\Favorites" h:\backup\%username%\Favorites *.* /e Robocopy "c:\documents and settings\%username%\application data\microsoft\templates" h:\backup\%username%\templates normal.dot Robocopy "c:\users\%username%\appData\Local\Microsoft\Office" h:\backup\%username%\Local *.Officeui Robocopy "c:\users\%username%\appData\Roaming\Microsoft\Office" h:\backup\%username%\Roaming *.Officeui regedit /e h:\backup\%username%\CustomDictionaries.reg "HKEY_CURRENT_USER\Software\Microsoft\Shared Tools\Proofing tools\Custom Dictionaries" echo Done pause ******************restore******************** Robocopy h:\backup\%username%\signatures "C:\documents and settings\%username%\application data\microsoft\signatures" *.* /e Robocopy h:\backup\%username%\NK2 "c:\documents and settings\%username%\application data\microsoft\Outlook" *.* /e Robocopy h:\backup\%username%\Desktop "C:\documents and settings\%username%\Desktop" *.* /e Robocopy h:\backup\%username%\Favorites "C:\documents and settings\%username%\Favorites" *.* /e Robocopy h:\backup\%username%\Local "c:\users\%username%\appData\Local\Microsoft\Office" *.* /e Robocopy h:\backup\%username%\Roaming "c:\users\%username%\appData\Roaming\Microsoft\Office" *.* /e regedit /c /s h:\backup\%username%\CustomDictionaries.reg echo Done
Seçilen Klasörde ki dosya sayısı ve Dosya Boyutları raporlar
Notped dosyası açılır, aşağıda ki kod txt dosyasına yapıştırılır ve vbs uzantılı dosyaya olarak kaydedilir.
Daha sora VBS uzantılı dosya çalıştırılması yeterlidir.
Dim objFSO, objFolder, objExcel, row, F, myVar1, myVar2, folderCount
Set objFSO = WScript.CreateObject("Scripting.FileSystemObject")
folderCount = 0
row = 2
''remove comment from next line for a browse to select folder option
Call browseFolder(strFolderSrc,"Source")
''remove comment from next line if you want a box you can type a path into
''for remote network drives use \\computername\sharename or C$
'strFolderSrc = InputBox("Type in the folder path" , "Enter path")
Set objFolder = objFSO.GetFolder(strFolderSrc)
'Write Header Row
Set objExcel = CreateObject("Excel.application")
objExcel.Workbooks.add
objExcel.Cells(1, 1).Value = "Folder Name"
objExcel.Cells(1, 2).Value = "Size (MB)"
objExcel.Cells(1, 3).Value = "# Files"
objExcel.Cells(1, 4).Value = "# Sub Folders"
objExcel.Visible = True
Wscript.Sleep 300
ShowFolderDetails objFolder, row
'Uncomment the following 2 lines to save and quit Excel on completion.
'objExcel.ActiveWorkbook.SaveAs("C:\\FolderReport.xlsx")
'objExcel.Quit
MsgBox "Complete."
Set objFSO = Nothing
Set objFolder = Nothing
Set objExcel = Nothing
Set row = Nothing
Set F = Nothing
Set myVar1 = Nothing
Set myVar2 = Nothing
Set folderCount = Nothing
WScript.Quit
'==========================================================================
'Functions
Function ShowFolderDetails(oF,r)
On Error Resume Next
objExcel.Cells(row, 1).Value = oF.Name
objExcel.Cells(row, 2).Value = oF.Size / 1024 / 1024
objExcel.Cells(row, 3).Value = oF.Files.Count
objExcel.Cells(row, 4).Value = oF.Subfolders.count
row = row + 1
'Comment out the following line and the loop to end the statement
'to list all subfolders.(End Loop is 6 lines down)
Do While folderCount < 1
for each F in oF.Subfolders
ShowFolderDetails F, row
Next
folderCount = folderCount + 1
Loop
End Function
' browseFolder brings up the selection box to choose both the source and the destination.
Function browseFolder(myVar1,myVar2)
Const WINDOW_HANDLE = 0
Const NO_OPTIONS = 0
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.BrowseForFolder _
(WINDOW_HANDLE, "Select a " & myVar2 & " folder:", NO_OPTIONS, "C:\\Scripts")
On Error Resume Next
Set objFolderItem = objFolder.Self
objPath = objFolderItem.Path
myVar1 = objPath
Call objPathChk(myVar1)
End Function
' objPathChk checks to make sure that a source has been selected.
Function objPathChk(myVar1)
If myVar1 = "" Then
MsgBox "Scan Folder Not Specified." & VbCrLf & _
"Scan will now quit.", vbOKOnly, "Terminate"
WScript.Quit
End If
End Function
Daha sora VBS uzantılı dosya çalıştırılması yeterlidir.
Dim objFSO, objFolder, objExcel, row, F, myVar1, myVar2, folderCount
Set objFSO = WScript.CreateObject("Scripting.FileSystemObject")
folderCount = 0
row = 2
''remove comment from next line for a browse to select folder option
Call browseFolder(strFolderSrc,"Source")
''remove comment from next line if you want a box you can type a path into
''for remote network drives use \\computername\sharename or C$
'strFolderSrc = InputBox("Type in the folder path" , "Enter path")
Set objFolder = objFSO.GetFolder(strFolderSrc)
'Write Header Row
Set objExcel = CreateObject("Excel.application")
objExcel.Workbooks.add
objExcel.Cells(1, 1).Value = "Folder Name"
objExcel.Cells(1, 2).Value = "Size (MB)"
objExcel.Cells(1, 3).Value = "# Files"
objExcel.Cells(1, 4).Value = "# Sub Folders"
objExcel.Visible = True
Wscript.Sleep 300
ShowFolderDetails objFolder, row
'Uncomment the following 2 lines to save and quit Excel on completion.
'objExcel.ActiveWorkbook.SaveAs("C:\\FolderReport.xlsx")
'objExcel.Quit
MsgBox "Complete."
Set objFSO = Nothing
Set objFolder = Nothing
Set objExcel = Nothing
Set row = Nothing
Set F = Nothing
Set myVar1 = Nothing
Set myVar2 = Nothing
Set folderCount = Nothing
WScript.Quit
'==========================================================================
'Functions
Function ShowFolderDetails(oF,r)
On Error Resume Next
objExcel.Cells(row, 1).Value = oF.Name
objExcel.Cells(row, 2).Value = oF.Size / 1024 / 1024
objExcel.Cells(row, 3).Value = oF.Files.Count
objExcel.Cells(row, 4).Value = oF.Subfolders.count
row = row + 1
'Comment out the following line and the loop to end the statement
'to list all subfolders.(End Loop is 6 lines down)
Do While folderCount < 1
for each F in oF.Subfolders
ShowFolderDetails F, row
Next
folderCount = folderCount + 1
Loop
End Function
' browseFolder brings up the selection box to choose both the source and the destination.
Function browseFolder(myVar1,myVar2)
Const WINDOW_HANDLE = 0
Const NO_OPTIONS = 0
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.BrowseForFolder _
(WINDOW_HANDLE, "Select a " & myVar2 & " folder:", NO_OPTIONS, "C:\\Scripts")
On Error Resume Next
Set objFolderItem = objFolder.Self
objPath = objFolderItem.Path
myVar1 = objPath
Call objPathChk(myVar1)
End Function
' objPathChk checks to make sure that a source has been selected.
Function objPathChk(myVar1)
If myVar1 = "" Then
MsgBox "Scan Folder Not Specified." & VbCrLf & _
"Scan will now quit.", vbOKOnly, "Terminate"
WScript.Quit
End If
End Function
16 Eylül 2014 Salı
15 Eylül 2014 Pazartesi
Ne kadar bilirsen bil, söylediklerin karşıdakinin anladığı kadardır.
Bir profesör konferans vermek üzere salona girmiş. Ama bakmış ki salon, ön sırada oturan seyis dışında boşmuş. Konuşup konuşmama konusunda tereddüde düşen profesör sonunda seyise sormuş:
-Buradaki tek kişi sensin. Sana göre konuşmalı mıyım, yoksa konuşmamalı mıyım?
Seyis cevap vermiş:
-Hocam ben basit bir insanım, bu konulardan anlamam. Fakat ahıra gelseydim ve bütün atların kaçıp bir tanesinin kaldığını görseydim, yine de onu beslerdim.
Bu sözlere hak veren Profesörkonferansa başlamış. İki saatin üzerinde konuşmuş durmuş, konferanstan sonra da kendini mutlu hissetmiş, dinleyicisinin de konferansın çok iyi olduğunu onaylanmasını isteyerek sormuş:
-Konuşmamı nasıl buldun?
Seyis cevap vermiş:
-Hocam sana daha önce basit bir adam olduğumu ve bu konulardan pek anlamadığımı söylemiştim. Gene de eğer ahıra gelir, biri dışında tüm atların kaçtığını görseydim, onu beslerdim; ama elimdeki tüm yemi ona verip de hayvanı çatlatmazdım.
Kissadan hisse:
"Ne kadar bilirsen bil, söylediklerin karşıdakinin anladığı kadardır."
-Buradaki tek kişi sensin. Sana göre konuşmalı mıyım, yoksa konuşmamalı mıyım?
Seyis cevap vermiş:
-Hocam ben basit bir insanım, bu konulardan anlamam. Fakat ahıra gelseydim ve bütün atların kaçıp bir tanesinin kaldığını görseydim, yine de onu beslerdim.
Bu sözlere hak veren Profesörkonferansa başlamış. İki saatin üzerinde konuşmuş durmuş, konferanstan sonra da kendini mutlu hissetmiş, dinleyicisinin de konferansın çok iyi olduğunu onaylanmasını isteyerek sormuş:
-Konuşmamı nasıl buldun?
Seyis cevap vermiş:
-Hocam sana daha önce basit bir adam olduğumu ve bu konulardan pek anlamadığımı söylemiştim. Gene de eğer ahıra gelir, biri dışında tüm atların kaçtığını görseydim, onu beslerdim; ama elimdeki tüm yemi ona verip de hayvanı çatlatmazdım.
Kissadan hisse:
"Ne kadar bilirsen bil, söylediklerin karşıdakinin anladığı kadardır."
11 Eylül 2014 Perşembe
SQL ilk 30 müşteri Cirosu için Sorgu
DECLARE @T1 AS VARCHAR(10)
DECLARE @T2 AS VARCHAR(10)
SET @T1='2013/01/01'
SET @T2='2013/12/31'
SELECT top 30 CH_KODU,B.AD,
SUM(CH_ISKONTOLUTOPLAM) TOPLAMCIRO
FROM STOK70E A, CARI00 B
WHERE A.TARIH BETWEEN @T1 AND @T2
AND A.CH_KODU=B.KOD
AND B.MUSTERI='E'
AND B.BOLGEKODU IN ('DOĞU')
GROUP BY CH_KODU,B.AD
ORDER BY TOPLAMCIRO desc
Excel Kelimeden öncesini kesmek için
Excel Kelimeden öncesini kesmek için kullanılan bir makro
Sub test()
For i = 2 To 999
If Cells(i, 1).Value = "" Then Exit For
aciklama = Cells(i, 1).Value
tmp = Split(aciklama, "arızası")
aciklama = tmp(0)
tmp = Split(aciklama, ",")
If UBound(tmp) > 0 Then
Cells(i, 5).Value = tmp(1)
Else
Cells(i, 5) = aciklama
End If
Next
End Sub
Vbs ile dosya kopyalama, sonuçları ise mail atma
vbs ile dosya kopyalama, sonuçları ise mail atma özelliğine sahip.
Yapılması gereken kodlar yedek.vbs adı ile kaydedilmelidir.
kaynak1 ="c:\yedekler"
hedefyer ="H:\MAYIS-2014"
YedekTarih="05-08-2014"
backupcmd1="/Y /E /I /s /d:"&YedekTarih
strSMTPFrom = "test@test.com"
strSMTPTo = "test@test.com"
strSMTPRelay = "10.10.1.1"
strSubject = "File copy completed"
kaynak1 = cleanPath(kaynak1)
hedefyer = cleanPath(hedefyer)
'MsgBox "File Copy Error: " & backupcmd1
Set WshShell = CreateObject ("Wscript.shell")
Set objExec = WSHshell.Exec("xcopy " & chr(34) & kaynak1 & "\SysState\*.*" & chr(34) & " " & chr(34) & hedefyer & "\SysState\" & chr(34) & backupcmd1)
strResult = ""
Do While Not objExec.StdOut.AtEndOfStream
strTemp = objExec.StdOut.ReadLine()
strResult = strResult & vbCRLF & strTemp
Loop
Set oMessage = CreateObject("CDO.Message")
oMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
oMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = strSMTPRelay
oMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
oMessage.Configuration.Fields.Update
oMessage.Subject = strSubject
oMessage.From = strSMTPFrom
oMessage.To = strSMTPTo
oMessage.TextBody = "Copy has completed, please review log for success/failure." & vbCRLF & vbCRLF & strResult
oMessage.Send
Function cleanPath(strPath)
If Right(strPath, 3) = "*.*" Then
strPath = Left(strPath, Len(strPath) - 3)
End If
If Right(strPath, 1) = "\" Then
strPath = Left(strPath, Len(strPath) - 1)
End If
cleanPath = strPath
End Function
hedefyer ="H:\MAYIS-2014"
YedekTarih="05-08-2014"
backupcmd1="/Y /E /I /s /d:"&YedekTarih
strSMTPFrom = "test@test.com"
strSMTPTo = "test@test.com"
strSMTPRelay = "10.10.1.1"
strSubject = "File copy completed"
kaynak1 = cleanPath(kaynak1)
hedefyer = cleanPath(hedefyer)
'MsgBox "File Copy Error: " & backupcmd1
Set WshShell = CreateObject ("Wscript.shell")
Set objExec = WSHshell.Exec("xcopy " & chr(34) & kaynak1 & "\SysState\*.*" & chr(34) & " " & chr(34) & hedefyer & "\SysState\" & chr(34) & backupcmd1)
strResult = ""
Do While Not objExec.StdOut.AtEndOfStream
strTemp = objExec.StdOut.ReadLine()
strResult = strResult & vbCRLF & strTemp
Loop
Set oMessage = CreateObject("CDO.Message")
oMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
oMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = strSMTPRelay
oMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
oMessage.Configuration.Fields.Update
oMessage.Subject = strSubject
oMessage.From = strSMTPFrom
oMessage.To = strSMTPTo
oMessage.TextBody = "Copy has completed, please review log for success/failure." & vbCRLF & vbCRLF & strResult
oMessage.Send
Function cleanPath(strPath)
If Right(strPath, 3) = "*.*" Then
strPath = Left(strPath, Len(strPath) - 3)
End If
If Right(strPath, 1) = "\" Then
strPath = Left(strPath, Len(strPath) - 1)
End If
cleanPath = strPath
End Function
Sub ayikla()
MERVE TİCARET - 3223651420 MERVE TİCARET 3223651420
Sub ayikla()
For i = 1 To 900
If Cells(i, 1).Value = "" Then Exit For
tmp = Cells(i, 2).Value
x = Split(tmp, "-")
For n = 0 To UBound(x)
Cells(i, 3 + n).Value = x(n)
Next
Next
End Sub
Son iki gün içinde oluşan ve değişen dosyaları xcopy ile kopyalamak
set /A dd=%dd% - 2
parametresi ile son iki gün içinde oluşan ve değişen dosyaları xcopy ile kopyalamak için tasarlandı.
@echo off
for /f "tokens=1" %%i in ('date /t') do set thedate=%%i
set mm=%thedate:~3,2%
set dd=%thedate:~0,2%
set yyyy=%thedate:~6,4%
echo.
echo Yedekleme Tarihi : %dd%-%mm%-%yyyy% %time%
echo.
if %dd%==08 (set dd=8 ) else (if %dd%==09 (set dd=9 ) )
if %mm%==08 (set mm=8 ) else (if %mm%==09 (set mm=9 ) )
set /A dd=%dd% - 2
set /A mm=%mm% + 0
if /I %dd% GTR 0 goto DONE
set /A mm=%mm% - 1
if /I %mm% GTR 0 goto ADJUSTDAY
set /A mm=12
set /A yyyy=%yyyy% - 1
:ADJUSTDAY
if %mm%==1 goto SET31
if %mm%==2 goto LEAPCHK
if %mm%==3 goto SET31
if %mm%==4 goto SET30
if %mm%==5 goto SET31
if %mm%==6 goto SET30
if %mm%==7 goto SET31
if %mm%==8 goto SET31
if %mm%==9 goto SET30
if %mm%==10 goto SET31
if %mm%==11 goto SET30
if %mm%==12 goto SET31
goto ERROR
:SET31
set /A dd=31 + %dd%
goto DONE
:SET30
set /A dd=30 + %dd%
goto DONE
:LEAPCHK
set /A tt=%yyyy% %% 4
if not %tt%==0 goto SET28
set /A tt=%yyyy% %% 100
if not %tt%==0 goto SET29
set /A tt=%yyyy% %% 400
if %tt%==0 goto SET29
:SET28
set /A dd=28 + %dd%
goto DONE
:SET29
set /A dd=29 + %dd%
:DONE
if /i %dd% LSS 10 set dd=0%dd%
if /I %mm% LSS 10 set mm=0%mm%
set YedekTarih=%mm%-%dd%-%yyyy%
echo Yedek islemi Basladi %YedekTarih% %time% > Yedekbasladi.out
set kaynak1=E:\yedekler
set hedef=\\192.168.1.2\yedek
set backupcmd= /Y /E /I /s /d:%YedekTarih%
xcopy "C:\Users Shared Folders\*.*" %hedef%\UsersFolders\ /Y /E /I /s > UserYedekDurum.out
echo Yedek islemi Bitti %YedekTarih% %time% > Yedekbitti.out
parametresi ile son iki gün içinde oluşan ve değişen dosyaları xcopy ile kopyalamak için tasarlandı.
@echo off
for /f "tokens=1" %%i in ('date /t') do set thedate=%%i
set mm=%thedate:~3,2%
set dd=%thedate:~0,2%
set yyyy=%thedate:~6,4%
echo.
echo Yedekleme Tarihi : %dd%-%mm%-%yyyy% %time%
echo.
if %dd%==08 (set dd=8 ) else (if %dd%==09 (set dd=9 ) )
if %mm%==08 (set mm=8 ) else (if %mm%==09 (set mm=9 ) )
set /A dd=%dd% - 2
set /A mm=%mm% + 0
if /I %dd% GTR 0 goto DONE
set /A mm=%mm% - 1
if /I %mm% GTR 0 goto ADJUSTDAY
set /A mm=12
set /A yyyy=%yyyy% - 1
:ADJUSTDAY
if %mm%==1 goto SET31
if %mm%==2 goto LEAPCHK
if %mm%==3 goto SET31
if %mm%==4 goto SET30
if %mm%==5 goto SET31
if %mm%==6 goto SET30
if %mm%==7 goto SET31
if %mm%==8 goto SET31
if %mm%==9 goto SET30
if %mm%==10 goto SET31
if %mm%==11 goto SET30
if %mm%==12 goto SET31
goto ERROR
:SET31
set /A dd=31 + %dd%
goto DONE
:SET30
set /A dd=30 + %dd%
goto DONE
:LEAPCHK
set /A tt=%yyyy% %% 4
if not %tt%==0 goto SET28
set /A tt=%yyyy% %% 100
if not %tt%==0 goto SET29
set /A tt=%yyyy% %% 400
if %tt%==0 goto SET29
:SET28
set /A dd=28 + %dd%
goto DONE
:SET29
set /A dd=29 + %dd%
:DONE
if /i %dd% LSS 10 set dd=0%dd%
if /I %mm% LSS 10 set mm=0%mm%
set YedekTarih=%mm%-%dd%-%yyyy%
echo Yedek islemi Basladi %YedekTarih% %time% > Yedekbasladi.out
set kaynak1=E:\yedekler
set hedef=\\192.168.1.2\yedek
set backupcmd= /Y /E /I /s /d:%YedekTarih%
xcopy "C:\Users Shared Folders\*.*" %hedef%\UsersFolders\ /Y /E /I /s > UserYedekDurum.out
echo Yedek islemi Bitti %YedekTarih% %time% > Yedekbitti.out
Excel diğer sayfadan veri çağırma.
Sayfa1 de ki A kolonu ile Sayfa2 B kayıtlar eşit ise Sayfa 2 veri yaz.
Sub FiyatGetir()
Dim Hucre As Range
Dim AramaAlani As Range
Set AramaAlani = Worksheets("Sayfa1").Range("A:A")
For Each Hucre In Worksheets("sayfa2").Range("B:B")
On Error Resume Next
Hucre.Offset(0, 3) = AramaAlani.Find(Hucre.Value).Offset(0, 3).Value
Next Hucre
End Sub
Excel Sayfa Biçimi Kopyala
Sub KOD()
Sheets("anasayfa").Columns("A:W").Copy
Sheets("aktarılan").Columns("A:W").PasteSpecial
Paste:=xlPasteFormats
End Sub
Excel VBA Makro ile nokta virgül değişimi
Sub Kod()
Application.ScreenUpdating =
False
Columns("A:D").Select
Selection.NumberFormat =
"#,##0.00"
Selection.Replace
What:=".", Replacement:=";"
Selection.Replace
What:=";", Replacement:="."
Selection.Replace
What:=",", Replacement:=""
Application.ScreenUpdating = True
MsgBox " B i t t i "
End sub
End sub
Excel İki sayfada benzeyen kayıtları tek sayaya toplar.
Excel İki sayfada benzeyen kayıtları tek sayaya toplar.
Sub ListeOluştur()
Set liste =
Sheets("Liste")
liste.Range("A:A").ClearContents
x = 2
For Each sayfa In Sheets
If sayfa.Name <>
liste.Name Then
For a = 1
To sayfa.Range("B65500").End(3).Row
For Each syf In Sheets
If syf.Name <> liste.Name Then
If WorksheetFunction.CountIf(syf.Range("B:B"), sayfa.Cells(a,
"B")) > 0 Then
say = 1
Else
say = 0
Exit For
End If
End If
Next
If
say = 1 And WorksheetFunction.CountIf(liste.Range("A:A"),
sayfa.Cells(a, "B")) = 0 Then
liste.Cells(x, "A") = sayfa.Cells(a, "B")
x = x + 1
End If
say = 0
Next
End If
Next
End Sub
Kaydol:
Kayıtlar (Atom)