Showing posts with label DOS. Show all posts
Showing posts with label DOS. Show all posts

Wednesday, July 21, 2010

DOS: SystemInfo

Problem Statement:
Using DOS command to get all the information pertaining to the sytem.

Solution:
Use of Dos coammnd: systeminfo.
Below is a typical output of systeminfo command on DOS prompt.


Using Perl Script to get OS Name:
use strict;
system("systeminfo find \"OS Name\" > C:\\temp\\temp.txt");
open(FH, "<", "C:\\temp\\temp.txt");
my $contents = ;
my @osInfo = split(':', $contents);
$osInfo[1] = s/\s\s+//g;
print $osInfo[1];

#This script would print the OS Name. Like it would print "Microsoft Windows 7 Utlimate" if run on Windows 7 - Ultimate Version of OS.

Tuesday, June 1, 2010

DOS: Create a 0KB file

Problem Statement:
I want to create a 0KB file using a DOS Command.

Here's how to do it:
Just Run->cmd and type in

goto >> "Filepath"

Since goto doesn't lead to any code execution its a command that is successful and since there is no return of the goto command, there is no data added to the file and hence the filesize is 0KB. Solves the purpose!

Just a try!
One could try "cls >> "Filepath" "; but this doesn't work as it adds a binary character in the file to be created.

Tuesday, May 4, 2010

DOS: Batch Script to enable Windows Logon through Registry

Problem Statement:
Script to enable Windows Logon through Registry changes.

Batch Script Contents:
REG ADD "HKLM\software\Microsoft\windows NT\CurrentVersion\Winlogon" /v DefaultUserName /t REG_SZ /d USERNAME /f
REG ADD "HKLM\software\Microsoft\windows NT\CurrentVersion\Winlogon" /v DefaultPassword /t REG_SZ /d PASSWORD /f
REG ADD "HKLM\software\Microsoft\windows NT\CurrentVersion\Winlogon" /v AuotAdminLogon /t REG_SZ /d 1 /f
REG ADD "HKLM\software\Microsoft\windows NT\CurrentVersion\Winlogon" /v ForceAutoLogon /t REG_SZ /d 1 /f **

**Note: Run the first three commands for Windows XP and above OS.
If working on Windows 2K use all the four commands.

Utility:
You could now use this script on the system where you want to enable auto logon.

You can get more methods on this at: http://www.logonexpert.com/freeautologon.html

Tuesday, April 27, 2010

DOS: Creation of HardLink in Windows

Problem Statement:
Creation of hardink in Windows

Solution:

This could be achieved by running the following on DOS prompt:
fsutil hardlink create c:\hlink.txt c:\log.log

Output of this command is:
Hardlink created for c:\hlink.txt <<===>> c:\log.log

Thus hlink.txt file is now a hardlink file for log.log.
Any changes made in log.log would reflect in hlink.txt file and vice-versa.
Also if any one file is deleted the other can be used as all contents would still be present in the other file.

Monday, April 26, 2010

DOS: Createfile of user-defined size

Hi Guys,

Here's something on our own, tried, tested and approved DOS commands.

Recently I came across a dos command that can create files of sizes that user needs. I thought this was useful and can used for:
- Creation of files as a test data
- Automation purposes based on the requirements
- For loading/stressing hard disk
- Boundary Value testing (since files can be craeted with least count of 1 Byte)
(Contributions by Sunil Ubranimath)

DOS Command:
fsutil file createnew c:\test.txt 2000

This creates a file test.txt on C:\ of 2000 Bytes. The data in the file is nothing but 'whitespaces'.


Other useful DOS commands:
C:\Documents and Settings\Chetan>fsutil
---- Commands Supported ----

behavior - Control file system behavior
dirty - Manage volume dirty bit
file - File specific commands
fsinfo - File system information
hardlink - Hardlink management
objectid - Object ID management
quota - Quota management
reparsepoint - Reparse point management
sparse - Sparse file control
usn - USN management
volume - Volume management