PPPoE Dialer via DOS Batch File
- Get link
- Other Apps
PPPoE Dialer via DOS Batch File
Waseem Anjum Meo@ 9:53 AM
10 Votes
8th Oct , 2013 9:30pm : Entry added to create network profile folder if not already there (usually on fresh win7)
9th Oct , 2013 01:45pm : Entry added to create new phonbook profile, it will not overwrite or delete previous one
♥
Following is a simple and quickest method to create pppoe dialer using MSDOS batch file made for Windows 7, which create a new rasphone profile for PPPoE Dialer. Usually this sort of work is done using VB , or VB/VC# .NET with Dotras type programming languages which does the job nicely with lots of options and fancy look menus etc, but due to my limited knowledge towards programming, I decided to go with my traditional CLI method. I created this batch program in a very short time without much googling.
↓
Phonebook Location to store profiles (new and old)
1
| %userprofile%\AppData\Roaming\Microsoft\Network\Connections\Pbk\ |
Any suggestion to improve the method will be highly appreciable . . . Please psot your comment if this batch file is working ok for you . . .
Let’s Start.
Create a new batch file like
notepad c:\dialer.bat
Paste following data and save.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
| @echo off rem rem ######################################### rem ### PPPoE Dialer Script for Windows 7 rem ### Syed Jahanzaib / aacable@hotmail.com rem ### http://aacablw.wordpress.com rem ######################################### rem ### Creating pppoe profile in a temporarily text file echo. 2> c:\rstemp.txt echo [AA_PPPoE_Dialer] >> c:\rstemp.txt echo Encoding=1 >> c:\rstemp.txt echo PBVersion=1 >> c:\rstemp.txt echo Type=5 >> c:\rstemp.txt echo AutoLogon=0 >> c:\rstemp.txt echo UseRasCredentials=0 >> c:\rstemp.txt echo LowDateTime=-582619296 >> c:\rstemp.txt echo HighDateTime=30327625 >> c:\rstemp.txt echo DialParamsUID=6326979 >> c:\rstemp.txt echo Guid=359A05BF4C146640949F56383A0F18F5 >> c:\rstemp.txt echo VpnStrategy=0 >> c:\rstemp.txt echo ExcludedProtocols=0 >> c:\rstemp.txt echo LcpExtensions=1 >> c:\rstemp.txt echo DataEncryption=8 >> c:\rstemp.txt echo SwCompression=0 >> c:\rstemp.txt echo NegotiateMultilinkAlways=0 >> c:\rstemp.txt echo SkipDoubleDialDialog=0 >> c:\rstemp.txt echo DialMode=0 >> c:\rstemp.txt echo OverridePref=15 >> c:\rstemp.txt echo RedialAttempts=3 >> c:\rstemp.txt echo RedialSeconds=60 >> c:\rstemp.txt echo IdleDisconnectSeconds=0 >> c:\rstemp.txt echo RedialOnLinkFailure=1 >> c:\rstemp.txt echo CallbackMode=0 >> c:\rstemp.txt echo CustomDialDll= >> c:\rstemp.txt echo CustomDialFunc= >> c:\rstemp.txt echo CustomRasDialDll= >> c:\rstemp.txt echo ForceSecureCompartment=0 >> c:\rstemp.txt echo DisableIKENameEkuCheck=0 >> c:\rstemp.txt echo AuthenticateServer=0 >> c:\rstemp.txt echo ShareMsFilePrint=0 >> c:\rstemp.txt echo BindMsNetClient=0 >> c:\rstemp.txt echo SharedPhoneNumbers=0 >> c:\rstemp.txt echo GlobalDeviceSettings=0 >> c:\rstemp.txt echo PrerequisiteEntry= >> c:\rstemp.txt echo PrerequisitePbk= >> c:\rstemp.txt echo PreferredPort=PPPoE4-0 >> c:\rstemp.txt echo PreferredDevice=WAN Miniport (PPPOE) >> c:\rstemp.txt echo PreferredBps=0 >> c:\rstemp.txt echo PreferredHwFlow=0 >> c:\rstemp.txt echo PreferredProtocol=0 >> c:\rstemp.txt echo PreferredCompression=0 >> c:\rstemp.txt echo PreferredSpeaker=0 >> c:\rstemp.txt echo PreferredMdmProtocol=0 >> c:\rstemp.txt echo PreviewUserPw=1 >> c:\rstemp.txt echo PreviewDomain=0 >> c:\rstemp.txt echo PreviewPhoneNumber=0 >> c:\rstemp.txt echo ShowDialingProgress=1 >> c:\rstemp.txt echo ShowMonitorIconInTaskBar=1 >> c:\rstemp.txt echo CustomAuthKey=0 >> c:\rstemp.txt echo AuthRestrictions=552 >> c:\rstemp.txt echo IpPrioritizeRemote=1 >> c:\rstemp.txt echo IpInterfaceMetric=0 >> c:\rstemp.txt echo IpHeaderCompression=0 >> c:\rstemp.txt echo IpAddress=0.0.0.0 >> c:\rstemp.txt echo IpDnsAddress=0.0.0.0 >> c:\rstemp.txt echo IpDns2Address=0.0.0.0 >> c:\rstemp.txt echo IpWinsAddress=0.0.0.0 >> c:\rstemp.txt echo IpWins2Address=0.0.0.0 >> c:\rstemp.txt echo IpAssign=1 >> c:\rstemp.txt echo IpNameAssign=1 >> c:\rstemp.txt echo IpDnsFlags=0 >> c:\rstemp.txt echo IpNBTFlags=0 >> c:\rstemp.txt echo TcpWindowSize=0 >> c:\rstemp.txt echo UseFlags=3 >> c:\rstemp.txt echo IpSecFlags=0 >> c:\rstemp.txt echo IpDnsSuffix= >> c:\rstemp.txt echo Ipv6Assign=1 >> c:\rstemp.txt echo Ipv6Address=:: >> c:\rstemp.txt echo Ipv6PrefixLength=0 >> c:\rstemp.txt echo Ipv6PrioritizeRemote=1 >> c:\rstemp.txt echo Ipv6InterfaceMetric=0 >> c:\rstemp.txt echo Ipv6NameAssign=1 >> c:\rstemp.txt echo Ipv6DnsAddress=:: >> c:\rstemp.txt echo Ipv6Dns2Address=:: >> c:\rstemp.txt echo Ipv6Prefix=0000000000000000 >> c:\rstemp.txt echo Ipv6InterfaceId=0000000000000000 >> c:\rstemp.txt echo DisableClassBasedDefaultRoute=0 >> c:\rstemp.txt echo DisableMobility=0 >> c:\rstemp.txt echo NetworkOutageTime=0 >> c:\rstemp.txt echo ProvisionType=0 >> c:\rstemp.txt echo PreSharedKey= >> c:\rstemp.txt echo NETCOMPONENTS= >> c:\rstemp.txt echo ms_msclient=0 >> c:\rstemp.txt echo ms_server=0 >> c:\rstemp.txt echo MEDIA=rastapi >> c:\rstemp.txt echo Port=PPPoE4-0 >> c:\rstemp.txt echo Device=WAN Miniport (PPPOE) >> c:\rstemp.txt echo DEVICE=PPPoE >> c:\rstemp.txt echo LastSelectedPhone=0 >> c:\rstemp.txt echo PromoteAlternates=0 >> c:\rstemp.txt echo TryNextAlternateOnFail=1 >> c:\rstemp.txt rem ### Removing white spaces so that it can be readable by phone book /zaib rem echo. 2> c:\rscompile.bat rem if [%1]==[] then echo File name missing & goto :EOF >> (for /f "tokens=1" %%a in (rstemp.txt) do echo %%a) > %~n1aa-rasphone.pbk rem ### Location for rasphone.pbk [just for reference] /zaib rem %userprofile%\AppData\Roaming\Microsoft\Network\Connections\Pbk\ rem ### Creating Network Profile Folder to store dialer profile, if its not there already mkdir %userprofile%\AppData\Roaming\Microsoft\Network mkdir %userprofile%\AppData\Roaming\Microsoft\Network\Connections mkdir %userprofile%\AppData\Roaming\Microsoft\Network\Connections\pbk cls rem Copy new rasphone.pbk to user network profile /zaib rem cd %userprofile%\AppData\Roaming\Microsoft\Network\Connections\Pbk\ rem ren rasphone.pbk rasphone.pbk.old copy c:\aa-rasphone.pbk %userprofile%\AppData\Roaming\Microsoft\Network\Connections\Pbk\ rem ### Create Network Connection Center Icon on Desktop /zaib rem ### I coulnd't found a way to create shortcut of dialer on desktop, someone please suggest set linkName=AA-Network Connections set linkPath=%userprofile%\desktop set program=C:\WINDOWS\SYSTEM32\ncpa.cpl set workDir=C:\WINDOWS\system32 set iconfile=%SystemRoot%\system32\SHELL32.dll set icon=-18 set windowStyle=2 echo Set oWS = WScript.CreateObject("WScript.Shell") > temp.vbs echo sLinkFile = "%linkPath%\%linkName%.LNK" >> temp.vbs echo Set oLink = oWS.CreateShortcut(sLinkFile) >> temp.vbs echo oLink.TargetPath = "%program%" >> temp.vbs echo oLink.IconLocation = "%iconFile%, %icon%" >> temp.vbs echo oLink.WindowStyle = "%windowStyle%" >> temp.vbs echo oLink.WorkingDirectory = "%workdir%" >> temp.vbs echo oLink.Save >> temp.vbs WScript.exe temp.vbs del temp.vbs rem # rem ### Show Popup Message box after everything completed /zaib rem # mshta
javascript:alert("Dialer Installation Completed!!!\n\Please Restart you
computern ,Thank You\n\Syed.Jahanzaib! aacable@hotmail.com");close(); rem # THE END # |
Now execute it from c:\dialer.bat & then restart your computer. If you dont want to restart the newly created connection will not show in network connections, You have to press F5 in the network connections to display the newly created profile. After restart it will appear auto in network and sharing center.
↓
After successful lab testing, its time to make it a distributable package. To convert it in executable package, you download BATCH to EXE converter.
extract and run Bat_To_Exe_Converter.exe
Fill up the required info as shown in teh images below and click on compile.
↓
and click on COMPILE , it will create .exe Package. You can also add additional info like ICON file , or product version or info
As showed in the image below . .
.
.
End results
↓
Regard’s
Syed Jahanzaib
April 3, 2013
Windows Server 2008 R2 Active Directory Reference Guide.
Filed under: Microsoft Related — Tags: Backup and Restore Active Directory in Server 2008, Import-Module ActiveDirectory, wbadmin, wbadmin start systemstaterecovery, windows 2008 active directory, windows 2008 backup — Syed Jahanzaib / Pinochio~:) @ 3:48 PM
8 Votes
Howto enable RECYCLE BIN in Widnows 2008 Active Directory Server.
Pre requisite to enable Recycle Bin in Windows 2008 Active Directory.1- Domain controller must be Windows 2008 R2 or later.
2- Forest and domain functional levels must be Windows Server 2008 R2, If not , then first raise functional level to windows 2008 R2 using ADUC
3- Enable Recycle Bin using Power Shell. Follow the below to do so
> Open powershell by using CMD and type powershell
> Load AD module by using following command.
Import-Module ActiveDirectoryNow activate Recycle BIN using following command
Enable-ADOptionalFeature -Identity ‘CN=Recycle Bin Feature,CN=Optional Features,CN=Directory Service,CN=Windows NT,CN=Services,CN=Configuration,DC=zaib,DC=com’ -Scope ForestOrConfigurationSet -Target ‘zaib.com’Note: Change the zaib , com and zaib.com to match your local domain name
Delete any single user from AD for test purpose
> Now delete any user for test purpose via AD or net command> From Powershell , Search for deleted items using following commands (TIP: To execute commands related to AD, always load module ActiveDirectory after you launch PowerShell)
Get-ADObject -Filter {name -like “*test*” -and deleted -eq $true} -IncludeDeletedObjectsNote: Change the *test to match the name or portion of delete user name
Restore Deleted User
To restore the deleted account, use following commandGet-ADObject -Filter {name -like “*test*” -and deleted -eq $true} -IncludeDeletedObjects | Restore-ADObjectIf you want to use GUI for easy access, then you can try ADRecycleBin.exe (Active Directory Recycle Bin) which allows administrators to quickly restore deleted Active Directory objects via an easy to use GUI (Graphical User Interface). This is a free Active Directory Recycle Bin tool. You can download it from
http://www.overall.ca/index.php?option=com_content&view=article&id=40:adrecyclebin&catid=15:adrecyclebinexe&Itemid=66
Backup and restore system state in windows 2008
Following is an small howto of ‘Backup and restore system state in windows 2008‘BACKUP
1- First install the backup features from the Server Manager.2- Open command prompt and type
wbadmin start systemstatebackup -backuptarget:d:and press enter. It will ask for confirmation, Type Y to continue
Note: You can use a different backup target of your choosing, it must be a local drive of your server.
When the backup finishes running, you should get a message that the backup completed successfully. Goto your backup drive and you will find folder name WindowsImageBackup with backup data.
RESTORE (Authoritative)
- To restore backup, Boot Windows 2008 in Directory Services Restore Mode (DSRM)- Open command prompt , First you need to get backup version number so that you may restore correct version of backup, use the followign command to get the version number
wbadmin get versions- Write down the version you need to use.
- To restore AD in AUTHORITATIVE mode (Usually used for DC), use the following command
wbadmin start systemstaterecovery -version:04/04/2013-15:00 –authsysvolNote: Change the -version: to match your backup number that noted from wbadmin get version command
- To restore AD in non-authoritative mode, remove the –authsysvol syntax at the end of the command (Usually used at ADC)
To get mroe info, please visit http://www.trainsignal.com/blog/backup-and-restore-active-directory-on-windows-server-2008 for more detailed step by step guide with snapshots
Regard’s
Syed Jahanzaib
March 26, 2013
Howto remove your mail server IP from HOTMAIL black list
Filed under: Microsoft Related — Tags: HOTMAIL black list, microsoft snds — Syed Jahanzaib / Pinochio~:) @ 1:32 PM
4 Votes
Recently Hotmail started to reject emails coming from our domain , giving following error.
Error transferring to mx4.HOTMAIL.COM; SMTP Protocol Returned a Permanent Error 550 SC-001 (SNT0-MC2-F23) Unfortunately, messages from xxx.xxx.xxx.xxx weren't sent.
Please contact your Internet service provider since part of their network is on our block
I checked at mxtoolbox.com website
mail server blacklist checker and all over the internet in all possible
dns black lists but my IP address was not listed and it was clean. I
then signed in to Microsoft Smart Network Data Services at https://postmaster.live.com/snds/ and found out that my IP address was in Hotmail black list.I found out that Microsoft has an Eform for De-Listing / removing spam black listed mail server IPs not able to deliver to Hotmail and live.com.
Fill out the below form
https://support.msn.com/eform.aspx?productKey=edfsmsbl2&ct=eformts
It will ask you Contact name, Contact e-mail address, Enter your Email Server Public IP in Outbound IP(s) or range(s) and submit, You will receive an ticket number and it may take upto 2-4 days for your request to be entertained. Hopefully they will remove it from there black list. It also happens if you sent email to any user and he mark it as junk/unwanted then it auto adds in Hotmail monitoring system.
TIP- 1: Using Internet Explorer I receive an error has occurred while submitting the above form, After using Firefox I was able to successfully submit the form.
More info can be found here.
http://pc-freak.net/blog/howto-remove-delist-your-mail-server-ip-from-hotmail-live-com-and-msn-mail-server-blacklist/
TIP- 2: In such situation when your public ip added to black list, you can use your ISP smtp/smart host to relay mail. This way your ip wont be used and usually ISPs maintain there mail relay system upto date.
Regard’s
Syed Jahanzaib
March 25, 2013
NTBACKUP commmon issue and there fixes
Filed under: Microsoft Related — Tags: Error 0×80042304, MOUNTING THE MEDIA, ntbackup, ntbackup volume shadow service error, rebuild RSM, Removable Storage, volume shadow copy:0x80042319, volume shadow copy:0xffffffff, volume shadow copy:80042319, volume shadow copy:ffffffff, Waiting for a previous media operation to finish — Syed Jahanzaib / Pinochio~:) @ 9:24 AM
5 Votes
In our company, we are using TAPE drives to backup our data on various servers. It was running successfully since many years, but from past few weeks, it started to create strange issues and backup were failing with multiple errors in logs , for example
Logs Error # 1
Volume shadow copy creation: Attempt 1. Timeout before function completed Error returned while creating the volume shadow copy:0x80042319. Error returned while creating the volume shadow copy:80042319 Aborting Backup. ---------------------- The operation did not successfully complete. ----------------------
Logs Error # 2
Volume shadow copy creation: Attempt 1. Timeout before function completed Error returned while creating the volume shadow copy:0xffffffff. Error returned while creating the volume shadow copy:ffffffff Aborting Backup. ---------------------- The operation did not successfully complete. ----------------------This error occurs when the creation of the Volume Shadow Copy times out.
This is more common during periods of high disk activity, or on disks that are heavily fragmented.
To solve it, Try following solutions
1- Make sure you have Latest Service pack for windows 2003 Server, If don’t Update it first,
Now Download HOTFIX from
http://support.microsoft.com/kb/833167/en-us
OR http://hotfixv4.microsoft.com/Windows%20Server%202003/sp1/Fix67560/3790/free/158865_ENU_i386_zip.exe
After applying, restart your server and try NTBACKUP again. If the problem persists, then continue below
2- Set following services startup type to AUTOMATIC , and start them
- Microsoft Software Shadow Copy Provider
- Virtual Shadow Copy
- Volume Shadow Copy (VSS)
- Remote Procedure Call (RPCSS) – should be enabled as “Automatic”
– COM+ Event System (eventsystem)
– System Event Notification Service (sens) – should be enabled as “Automatic”
Adjust above services accordingly and now try NTBACKUP again.
3- Re-Register few dll’s ,Open command prompt and copy paste following lines.
Net stop vss
Net stop swprv
regsvr32 ole32.dll
regsvr32 oleaut32.dll
regsvr32 vss_ps.dll
vssvc /Register
regsvr32 /i swprv.dll
regsvr32 /i eventcls.dll
regsvr32 stdprov.dll
regsvr32 es.dll
regsvr32 vssui.dll
regsvr32 msxml.dll
regsvr32 msxml2.dll
regsvr32 msxml3.dll
regsvr32 msxml4.dll
Now Restart your server and try NT.Backup again. Hopefully it will work fine , at least in my case, it DID
Mounting the media . . .
If you run NTBackup from Windows, and it says “Waiting for a previous media operation to finish” but actually there is none. OR if you see MOUNTING THE MEDIA and it keep stucked on this message. Then Try following . . .Go to Computer Management -> Removable Storage and check under the Work Queue for any errors. Deleting any jobs that are failing should resolve your problem. However, you may be experiencing hardware issues with the drive or the media, which would be worth checking out.
In some cases restarting the Removable Storage service has worked OR
In some cases, rebuilding the Removable Storage Database has worked for me.
To rebuild RSM Database, Follow below steps
1) Go to Start > Control Panel > Administrative Tools > Services and find the Removable Storage service.2) Right click on the Removable Storage service, select Properties, change the ‘Startup type:’ to Disabled and click ok.
3) Restart the machine
4) When the machine is running again open Windows Explorer and navigate to the C:\Windows\system32\ntmsdata\ directory (or some other variation depending on the operating system, just pick the directory where Windows is installed and go from there)
5) In that directory rename all the files to *.OLD or move them to another temp folder.
6) Go back to the Removable Storage service (see step 1) go to properties and change the ‘Startup type:’ back to Automatic.
7) Restart the machine again
The device reported an error on a request to write data to media.
IF you receive the following error in NTBACKUP logsError: The device reported an error on a request to write data to media.
Error reported: Bad data.
There may be a hardware or media problem.
# Clean your tape drive either by using Cleaning Tape or other means (by service technician)
Regard’s
Syed Jahanzaib
March 5, 2013
Windows 2008 Group Policy ! Fun Things to DO
Filed under: Microsoft Related — Tags: Disabling Action Center's Firewall Notification through GPO, Howto disable Windows Firewall using Group Policy in Windows 2008 — Syed Jahanzaib / Pinochio~:) @ 4:25 PM
6 Votes
Howto disable Windows Firewall using Group Policy in Windows 2008
I personally don’t think it’s the best way to disable windows firewall specially in a large network environment, but recently I was in a situation where I needed it to avoice some arguments with few co workers. Here is how you can do it on a Windows 2008 server.Open Group Policy Management,
Select the policy to edit (Usually: the default policy), right-click and choose Edit.
Go to Administrative Templates > Network > Network connections > Windows Firewall > Domain Profile.
Disable the “Protect All Network connections” rule. Do the same for the “Standard Profile”, as well.
Now, all that’s left to do is update the clients. Default Update time for group policy is 6 hours, but you can push it forcefully by using following command:
gpupdate / force
then simply log off and log on the client again.
Disabling Action Center’s Firewall Notification through GPO
As far as I know, there is not a policy that will disable only the Firewall Notification. The closest options we could configure are two policies that are related but neither is really a complete solution and will block other types of notifications as well:1) Disable all balloon notifications:
User Configuration \ Administrative Templates \ Start Menu and Taskbar \ Turn off all balloon notifications
2) Disable Action Center itself:
User Configuration\Administrative Templates\Start Menu and Taskbar \ Remove the Action Center icon
(Thanks for the TIP from http://social.technet.microsoft.com/Forums/en-US/winserverGP/thread/e78a30cb-6cf2-4de6-afda-e0c90a3d2e34/ )
Disabling Your Security setting level puts your computer at risk notification
If your users are complaining of the appearance of the message box in Internet Explorer 7/8 telling that“Your Security setting level puts your computer at risk.”
To fix it, There are two ways to resolve this:
1. Set “Initialize and script ActiveX controls not marked as safe for scripting” to Disable (recommended) under Security Settings – Internet Zone or Restricted Sites Zone
2. Enable the following GPO via Domain Group Policy at your Domain controller.
Goto Local Computer Policy
User Configuration
Administrative Templates
Windows Components
Internet Explorer
ENABLE this setting > Turn off the Security Settings
Regard’s
Syed Jahanzaib
February 22, 2013
Start windows service under different user credentials
Filed under: Microsoft Related — Tags: net start, sc.exe, start windows service with another user credential — Syed Jahanzaib / Pinochio~:) @ 3:02 PM
5 Votes
To start windows service under another user credentials , Use following
In Windows 2003:
IF the user belongs to local system
sc.exe config SERVICENAME obj= .\USERNAME password= 123456
net start “SERVICENAME”
OR
IF the user belongs to Domain
sc.exe config SERVICENAME obj= DOMAIN_NAME\syed.jahanzaib password= 123456
net start “SERVICENAME”
TIP: Make sure you add SPACE after each equal sign in command .It was required for me to start SAP services, after configuring user account with password in services console, they remove password after every restart of system, therefore I made this batch file to execute on startup so they start automatically upon reboot.
For example: obj= SERVICENAME
Regard’s
Syed Jahanzaib
January 16, 2013
Active Directory DSQUERY & Miscellenous Commands with Syntax
Filed under: Microsoft Related — Tags: dsget, dsquery, net use, Show All Users Created Since, Show DISABLED Users Only, Show Inactive Users Only, Show Users For Specific Period — Syed Jahanzaib / Pinochio~:) @ 2:02 PM
10 Votes
Recently We were asked by the Auditors to provide some data of Active Directory for yearly Audit purpose. I already have few scripts that saved a lot of time. I also linked these scripts with the Linux base WEBMIN, so they can be called by nice GUI as showed in the example below.
.
<How to link Linux base scritps with the webmin>
Following are scripts
Show All users in your domain
dsquery * dc=yourdomainname -filter “(&(objectCategory=Person)(objectClass=User))” -limit 0
Show All Users Created Since 1st January, 2012 till date
dsquery * dc=yourdomainname -filter “(&(objectCategory=Person)(objectClass=User)(whenCreated>=20120101000000.0Z))”
Show Users For Specific Period (Jan-2012 till Dec-2012)
e.g: Display Users Created from 1st January 2012 till 31st December 2012 (1 Year) Only.
dsquery * dc=yourdomainname -filter “(&(objectCategory=Person)(objectClass=User)(whenCreated>=20120101000000.0Z-)(whenCreated<=20121231000000.0Z-))”
> = greater then
< = less then
~ = approx
= equals
Miscellaneous commands . . .
Show All Users Info (Active/Non Active)dsquery user -limit 0 | dsget user -dn -disabled
Show Inactive Users Only (Users that haven’t logged on since last 2 weeks)
dsquery user “dc=Your_Domain_Name” -inactive 2
Show DISABLED Users Only
dsquery user -disabled | dsget user -display -email -dept -title
Show ACTIVE Users Only
dsquery * -filter “(&(sAMAccountType=805306368)(!(userAccountControl:1.2.840.113556.1.4.803:=2)))” -limit 0 | dsget user -display -email -dept -title
Show Users from Specific Group Only
dsquery group DC=yourdomainname -name “Type Group Name” | dsget group -members |sort |dsget user -display -email -dept -title
Show Only Specific User Details
Net user USERID /domain
Delete Only Computer Name from AD Computers
dsquery computer -name PCNAME |dsrm -subtree -c -noprompt
Regard’s
Syed Jahanzaib
Backup Files via CMD/Batch/ntbackup Scripts [Personnel Notes]
Filed under: Microsoft Related — Tags: batch file to delete files older then n days, dos batch file — Syed Jahanzaib / Pinochio~:) @ 8:55 AM
10 Votes
Salam to All,
Following are few backup batch files that I have used at my office to perform backup operation using scheduled backup tasks. I am posting them just for reference so they can be used as archiving or possibly useful for others too having same task.
+++++++++++++++++++++++++++++++++++++++
Few days back, a new oracle server was added in our IT dept. It is an oracle database server which serves many users request in our company. There was an annoying manual backup task that we have to perform on it on daily basis , the :@ task was to run 2 shortcut which creates backup dump files in E: drive, and then we have to manually rename the 2 dump files according to current date and then move them in other date-wise folder.
Quite annoying , isn’t it ? I mean still do we have to perform simple tasks like taking backup manually where every task is being done Automatically ?
Stupid enough !
It was quite easy to do this task automatically in LINUX environment, but as currently i am working in MS (Microshit or Microsoft environment) I manage to done it with built-in DOS commands. Following is the complete dos batch file or call it the Backup script , I just added in Schedule task, Now it runs daily and saves my time.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
| @echo off Echo Oracle Backup Organizer Script. Echo Developed by Syed Jahanzaib / aacable@hotmail.com Echo Make sure you have the backkup folder where backup is copied on daily basis by other script. Echo Setting current date set dt=%date:~-4,4%%date:~-10,2%%date:~-7,2% Echo Map File Server backup folder in local computer using admin account. net use B: \\FILES_SERVER\D$\home\cic /USER:zaib-admin@localdomain admin-passwd Echo Copying already created oracle Dump files (which you can create by using backup file scheduled to run daily) Echo into remote file server with current date for backup - FILES_SERVER copy e:\backup\Cic_final.Dmp B:\cic-backup.%dt%.dmp copy e:\backup\nae_final.dmp B:\nae-backup.%dt%.dmp Echo Renaming dump files to current date for the date wise backup ren e:\backup\Cic_final.Dmp cic-backup.%dt%.dmp ren e:\backup\nae_final.dmp nae-backup.%dt%.dmp echo. echo All Backup done. Allah Hafiz |
NTBACKUP with EMAIL the LOGS and START/END Time Report
This Script will first backup the data defined in “backup-data” to Tape Drive (In my case it was IBM LTO-3) and then email the LOG to your defined email addresses (in “mail-to” section) It will also record the total time of the backup and will attache it to the email.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
| @echo off rem # Syed Jahanzaib # SERVER X Backup SCRIPT rem ####################################################### rem Setting various Descriptions via environment variables rem ####################################################### setlocal enableextensions enabledelayedexpansion set starttime=%time% set dt=%date:~-4,4%%date:~-10,2%%date:~-7,2% set logpath="C:\Documents and Settings\Administrator\Local Settings\Application Data\Microsoft\Windows NT\NTBackup\data" set srvname=SERVERx set backup-data=C:\backup\FULL-backup.bks set description=Full Backup for My Server / ZAIB set jobname=Full Backup for My Server / ZAIB set attachment=C:\backup\serverx-ntbackup-%dt%.log set mail-subject=Full Backup LOG for My Server / ZAIB set mail-body=Full Backup LOG for My Server / ZAIB set mail-to="aacable@hotmail.com","myemail2@xyz.com" set footer=Automated Backup & Email Logs Script Created by Syed Jahanzaib rem set stopsap=C:\BACKUP\STOPSAP_R3D.cmd rem set startsap=C:\BACKUP\STARTSAP_R3D.cmd rem ############################## rem Stopping SAP & ORACLE Services rem ############################## rem %stopsap% rem ###################################### rem Starting Backup in IBM LTO3 Tape Drive rem ###################################### start
/wait C:\WINDOWS\system32\ntbackup.exe backup "@%backup-data%" /n
"%jobname%" /d "%description%" /j "%jobname%" /l:s /p "LTO Ultrium" /UM
/v:no /r:yes /rs:no /hc:on /m normal rem ############ rem NTBackup END rem ############ rem ### Copy current date LOG to C:\backup for email purpose forfiles -p %logpath% -s -m *.log -d 0 -c "cmd /c copy @file %attachment%" rem ######################### rem STart END Time Algorithm rem ######################### ping -n 2 127.0.0.1 >nul: 2>nul: set endtime=%time% set total="echo Total = %tot%" set /a hrs=%endtime:~0,2% set /a hrs=%hrs%-%starttime:~0,2% set /a mins=%endtime:~3,2% set /a mins=%mins%-%starttime:~3,2% set /a secs=%endtime:~6,2% set /a secs=%secs%-%starttime:~6,2% if %secs% lss 0 ( set /a secs=!secs!+60 set /a mins=!mins!-1 ) if %mins% lss 0 ( set /a mins=!mins!+60 set /a hrs=!hrs!-1 ) if %hrs% lss 0 ( set /a hrs=!hrs!+24 ) set /a tot=%secs%+%mins%*60+%hrs%*3600 echo End = %endtime% echo Start = %starttime% echo Hours = %hrs% echo Minutes = %mins% echo Seconds = %secs% echo Total = %tot% rem ########## rem Email LOGS rem ########## c:\blat\blat.exe
-to %mail-to% -i %srvname% -s "%mail-subject%" -body
"%mail-body%|Backup Report:|Start = %starttime%|End =
%endtime%|Hours = %hrs%|Minutes = %mins%||%footer%" -attach
%attachment% endlocal rem ############################## rem Starting SAP & ORACLE Services rem ############################## rem %startsap% rem ## THE END ### rem ## Syed Jahanzaib |
To delete files olde then X days using FORFILES
forfiles /p “C:\test” /s /m *.* /c “cmd /c del @path” /d -15
Change /d -15 to match your requirements.
you can change the del command to any other like to show the files, use
echo. FORFILES is builtin command with Windwos 2003 /7. You can download
it from
http://www.ipass.net/davesisk/forfiles.zip
http://www.ipass.net/davesisk/forfiles.zip
Delete Files Over 15 Days Old using ROBOCOPY
set _robodel=%TEMP%\~robodel
MD %_robodel%
ROBOCOPY “C:\source_folder” %_robodel% /move /minage:15
del %_robodel% /q
Batch File to create SQL Backup
First create .sql file that can be called from batch file to create any specific DB backup.for example c:\zaibdb.sql
1
2
| BACKUP
DATABASE [Promo] TO DISK = N'D:\DataBaseBackup\zaibdb.Bak' WITH
NOFORMAT, INIT, NAME = N'Promo-Full Database Backup', SKIP, NOREWIND,
NOUNLOAD, STATS = 10 GO |
for example c:\start_backup.bat
1
2
3
4
5
6
7
8
9
10
| @echo off echo Creating FULL backup in D:\zaibdb.back echo %Date% >> D:\DataBaseBackup\zaibdb.txt sqlcmd -S .\SQLEXPRESS -i c:\zaibdb.sql > D:\DataBaseBackup\zaibdb.txt echo. echo Done rem ping 127.0.0.1 -n 10 > null echo . >> D:\DataBaseBackup\zaibdb.txt echo This backup set was last created at %Date% >> D:\DataBaseBackup\zaibdb.txt echo. |
Another Backup script that map remote server folder locally
and then copy the required files and then delete the files older then 20 days
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
| @echo off rem Syed Jahanzaib / ??? (Pvt) Ltd. IS Dept. rem This file will copy the today's SAP exports and cofiles only to files_server\export folder, rem which is actually mapped locally as B: drive. rem # rem # rem # rem # Mapping files_server Folder via agpis Credentials net use B: \\files_server\ rem # Copying Last Date Export files to \\file-server\B:\export folder forfiles -p "J:\required_folder" -s -m *.* -d 0 -c "cmd /c copy @path B:\" rem # Copying Last Date cofiles data to \\file-server\B:\cofiles folder forfiles -p "J:\required_folder" -s -m *.* -d 0 -c "cmd /c copy @path B:\" rem # Deleting export older then 20 Days . . . forfiles -p "J:\required_folder" -s -m *.* -d -20 -c "cmd /c del @path" rem # Deleting cofiles Logs older then 20 Days . . . forfiles -p "J:\required_folder" -s -m *.* -d -20 -c "cmd /c del @path" |
Daily Backup of Required Folder using ROBOCOPY
Robocopy method which will copy only new file by matching source and destination folder/file timstamps. Its much better as it displays results in command prompt with percentage and all the necessary info any admin want. its my favorite. You can downlod Robocopy by downloading Microsoft Resource Kit from following link.http://www.microsoft.com/en-us/download/details.aspx?id=17657
1
2
3
4
5
6
| @echo off Robocopy /E /LOG+:h:\Softwares\Servers_Related\mail-backup-log.txt B:\archive\. T:\backup\archive Robocopy /E /LOG+:h:\Softwares\Servers_Related\mail-backup-log.txt T:\mailserver\c$\mt\. T:\backup\mt Robocopy /E /LOG+:h:\Softwares\Servers_Related\mail-backup-log.txt T:\mailserver\mail\. T:\backup\mail |
/E = Copy sub-directories, including Empty ones
/LOG + = Output status to LOG file (append to existing log, so previous entries along with new one should be saved together, if you don’t use + , it will overwrite existing log-file, means delete old entries and overwrite new one)).
XCOPY Method
Following file will copy all the data from the source folder to target folder using windows builtin copy tool XCOPY.
1
2
3
4
5
6
7
8
9
| @echo off echo * * * >> C:\backup-log.txt echo Mail Backup Starts at %date% - %time% >> C:\backup-log.txt C:\windows\system32\xcopy.exe B:\source-folder\*.* T:\targetfolder /S /D /C /Y echo Mail Backup Ends at %date% - %time% >> C:\backup-log.txt echo * * * >> C:\backup-log.txt |
/S = Copies directories and sub-directories except empty ones.
/D = If no date is given, copies only those files whose source time is newer than the destination time.
/C = Continues copying even if errors occur.
/Y = Overwrite existing files if any without prompting, its necessary when you are running xcopy via batch / script file.
Regard’s
Syed Jahanzaib
January 10, 2013
Personnel short notes for BLAT and Delete Files Older then X Days
Filed under: Microsoft Related — Tags: blat, email using BLAT, forfiles, howto delete files older then x days — Syed Jahanzaib / Pinochio~:) @ 10:50 AM
5 Votes
To send email from windows command using your local company SMTP , use BLAT tool.
BLAT guide.
A wonderful guide is already available here.
http://cybergav.in/2010/10/28/how-to-send-emails-using-blat/
+++++++++++++++
First Download BLAT from following URL:
http://sourceforge.net/projects/blat/files/Blat%20Full%20Version/32%20bit%20versions/Blat%20v3.0.0/blat300_32.full.zip/download?use_mirror=autoselect
Unzip it to any folder you like.
+++++++++++++++
To install SMTP in BLAT use the below command . . .
blat -installSMTP 10.0.0.1 your-user-id@xyz.com.pk 5 25
+++++++++++++++
To send email using blat command, use the below command
blat -s “test mail” -i “test” -to your-user-id@xyz.com.pk
+++++++++++++++
To send email with attachment of file using blat command, use the below command
blat -s “test mail” -i “Syed Jahanzaib / Admin” -to your-user-id@xyz.com.pk -body “Please see attached file” -attach c:\test.txt
+++++++++++++++
Email/Delete Files OLDER then X days Examples:
CORE EXAMPLEforfiles -p “C:\test” -s -m *.* -d 0 -c “cmd /c c:\blat\blat.exe -to your-user-id@xyz.com.pk -i myname -s INFRA_LOGS -body INFRA_SERVERS_LOGS -attach @path”
Working EXAMPLE for file_server/ For TAPE BACKUP LOGS
forfiles -p “C:\Documents and Settings\Administrator\Local Settings\Application Data\Microsoft\Windows NT\NTBackup\data” -s -m *.* -d 0 -c “cmd /c c:\blat\blat.exe -to your-user-id@xyz.com.pk -i myname -s INFRA_LOGS -body INFRA_SERVERS_LOGS -attach @path”TO show (DELETE removed from syntax) FILES OLDER THEN X DAYS (in the below example its 30 days)
FORFILES /p c:\temp /d -30 /m * /c “cmd /c echo @file”TO show (DELETE removed from syntax) FILES For TODAY
FORFILES /p c:\temp /d 0 /m * /c “cmd /c echo @file”Windows 2003/7/2008 already have forfiles installed. but you can download it from here http://www.ipass.net/davesisk/forfiles.zip
.
Regard’s
Syed Jahanzaib
Howto send email from command via Windows using GMAIL account
Filed under: Microsoft Related — Tags: email from command, mailsend, send email via command in windows — Syed Jahanzaib / Pinochio~:) @ 10:37 AM
4 Votes
Send Email from Windows via command prompt using GMAIL Account ~
If you want to send email from windows using command prompt using gmail account, first down mailsend utility from following URL and extract it to any folder you like.
http://www.muquit.com/muquit/software/mailsend/mailsend1.16.exe.zip
Now to send email using command via your GMAIL account, use the below syntax. Remember to change the email addressees and password to match your account details.
1
| mailsend.exe
-to aacable@hotmail.com -from your-gmail-id@gmail.com -ssl -smtp
smtp.gmail.com -port 465 -sub "Testing Email via Windows cmd using GMAIL
test %time%" -M "This is body text of Testing Email via Windows cmd
using GMAIL. %date% %time% sending / zaib." +cc +bc -q -auth-plain -user
"your-gmail-id" -pass "yourpass" |
1
| mailsend.exe
-to aacable@hotmail.com -from your-gmail-id@gmail.com -ssl -smtp
smtp.gmail.com -port 465 -sub "Testing Email via Windows cmd using GMAIL
test %time%" -M "This is body text of Testing Email via Windows cmd
using GMAIL. %date% %time% sending / zaib." +cc +bc -q -auth-plain -user
"your-gmail-id" -pass "yourpass" -attach "c:\test.txt" |
.
For more info, please read this details guide at
http://www.codeproject.com/Tips/418420/Send-email-from-command-line-using-GMail-account
.
Regard’s
Waseem Anjum Meo
- Get link
- Other Apps
A very interesting article. The insights are really helpful and informative. Thanks for posting. Visit here for more info.
ReplyDeleteD-link australia
D-link Customer Support
dlink admin password