Ok? Do I have a choice??


Windows/DOS commands

DOS/CLI commands

xcopy d:\ z: /s /e /c /f /z /h	# xcopy from d: to z: , include sub dir, hidden file, etc.


robocopy s:\source\folder1 d:\destination\folder2 /e /move /copyall /tee /log+:robo.log  /w:1 /r:2

	# Robust copy, lot of options, separate tool from MS?
	# /move = move files and dirs  (hopefully not copy and delete if on same FS)
	# /copyall = copy NTFS ACL, owner, and audit info also (these are not included by default)
	# 		but if ACL cannot be copied, copy will fail (reported)
	# /e	= include sub dirs, even if empty
	# /tee /log+:robo.log will do a "T" and append to log file
	# /w:1 /r:2 = wait 1 sec before retry, max 2 retries  
	#  		(good if know waiting won't help unlock file, or will do multi-scan)
	#
	#
	# Note that folder1 itself won't be moved, it is the content inside the folder
	# It is more like folder1\* to folder2.  
	# But folder1 itself will be deleted if /MOVE is used.
	# Don't think too much like Unix!   
	
	# Additional notes:
	# File that cannot be moved (cuz it is locked) 
	# is not reported as error in summary (but as skipped?).
	# But instead of whining and stopping if using the Win Explorer GUI, 
	# Robocopy will continue to move the next file.
	#
	# Files created after Robocopy completes its indexing are not touched.
	#
	# Redirecting output to a log file is good, as it is quite verbose.
	# \\unc\path can be used.
	# 
	# files that already exist in the destination are reported as EXTRA
	# can be /purge if desired.



cacls		= change acl's.  NT cli version of solaris setfacl.
compact		= file compression util (list, maybe set?)




type file | find /i "string"
	# equiv to unix cat file | grep -i string
	# the quotes MUST be used or 
	# find will complain with weired error message!
	# /i = case Insensitive grep.
type file | findstr /i "string"
	# similar to find above, but different binary...

rdisk		= nt4 create emergency recovery disks (erd)

regback		= registry backup (add on?)


title any text string desired
	Set the DOS CLI window to have the desired title


bgjob prog arg
	run bg job inside a telnet session
	so that even if telnet goes away, job remains.
	There is still probably a nohup.
---

BATCH script

Sample .bat file:

@echo off
CLS
assoc .dxp=dxpfile >NULL 
REM ftype dxpfile="C:\winnt\system32\notepad.exe" "%%1"

echo.
echo.
echo.
echo.

if exist "C:\Program Files\TIBCO\Spotfire\3.0\Spotfire.Dxp.exe" (
  ftype dxpfile="C:\Program Files\TIBCO\Spotfire\3.0\Spotfire.Dxp.exe" "%%1"  >NULL
  echo "Updated dxp extension for SpotFire 3.0
  goto theend
) 

if exist "C:\Program Files\TIBCO\Spotfire\2.1\Spotfire.Dxp.exe" (
  ftype dxpfile="C:\Program Files\TIBCO\Spotfire\2.1\Spotfire.Dxp.exe" "%%1"  >NULL
  echo "Updated dxp extension for SpotFire 2.1
  goto theend
)

echo "No SpotFire found in standard directory locations, no changes made."

:theend
echo.
echo.

pause
exit 0




Alternate Data Stream

echo "main stream" > stream.txt
echo "alternate stream" > stream.txt:ads  

not supported in NFS.
Similar stuff on Apple's HFS?

windows network stuff


net use R: \\host\share password /user:DOMAIN\USERNAME
	map network drive; funky session weireness, watch out use in script

net view

net user USERNAME PASSWORD /add
	add user


net statistics server		# info about uptime, etc





tracert
nbtstat -n 	= list all comp (NetBIOS name, WINS)
nbtstat -c	= clear the cache
nbtstat -RR	= Release and Reregister NetBIOS name with WINS

NetBIOS names can only be 15 chars long. The 16th char encode the NetBIOS Suffix.
A list (albeit not comprehensive, at least 4F is not listed) can be found at http://support.microsoft.com/kb/163409
All code in hex
00 = Workstation Service
03 = Manager Service (allow MMC to connect to it?)
1B = Domain Master Browser, defined for a domain rather than a computer
1C = Domain Controllers, defined for a domain
20 = File Server Service




netsh (shell for config of dhcp, ras, wins, routing) [w2k]

runas  	# kind of like sudo

runas /user:domain\adminUser c:\winnt\system32\cmd.exe		# create a dos prompt with admin credentials
      c:\"Program Files\Internet Explorer\iexplore.exe"		# start IE using the credential of the DOS session (ie admin acc).



set	# display system environment
	# LOGONSERVER is the Domain Controller the machine is currently talking to
	# Other interesting variables displayed by set:
	# USERNAME, USERDOMAIN 
	# PROCESSOR_ARCHITECTURE


----

network browser cmd (some gui stuff) in Resource or Supplement kit.

net config rdr, see network device info, eg NetBT_E100B1
then, 

browstat gb NetBT_E100B1
   tell which one is the master browser in the network.

browmon	
   GUI browser monitor.  similar to above


browstat status
browstat view NetBT_E100B1 NTDOM1
browstat getpdc NetBT_E100B1 NTDOM1


other obscure stuff, w2k only?
    browstat dumpnet


netusers  \\computername   /history
		# see who has logged in to a given machine

mmc		# win magement console, 
		# many plugin, eg computer mgnt
		# customizable and store them as .msc file

http://www.windowsnetworking.com/kbase/WindowsTips/Windows2003/AdminTips/Admin/LaunchAdminToolsfromtheCommandLine.html


nt4 / w2k reousrce pack

shutdown 
		\\computer	: remote computer to shutdown (local if omitted)
		/A			: abort shutdown
		/R 			: reboot
		/T:xx		: wait xx secs (def=30)
		msg			: message to user of shutdown
		/C 			: force running app to close

Windows Registry

reg query HKCR\dxpfile
reg add
reg delete
reg export  ROOTKEY/subkey regdump.reg

Did not find command line equivalent of doing find on all fields and repeat using regedit and F3 ... 
can't export and do grep either :(


accepted abbreviations (likely in order of decreasing priority):
HKCR    HKEY_Classes_ROOT
HKCU	HKEY_CURRENT_USER    (take precedence over local_machine if there are duplicates)
HKLM	HKEY_LOCAL_MACHINE
HKU?    HKEY_USERS
HKCC?   HKEY_CURRENT_CONFIG

Windows Startup

windows program auto load, from registry instead of Startup folder:

regedit


HKLM\Software\Microsoft\Windows\CurrentVersion\Run
HKCU\Software\Microsoft\Windows\CurrentVersion\Run

TLA (likely in order of decreasing priority):
HKCU	HKEY_CURRENT_USER    (take precedence over local_machine if there are duplicates)
HKLM	HKEY_LOCAL_MACHINE

each program has an entry with full path as value, delete individually as needed.
XP has a System Configuration Utility under control panel | help support 
section, so that all current startup places are listed and can be turned off via uncheck.

Many of these can be recognized as normal software, but just always run
at startup, which becomes anoying.

Some spyware may also add hooks here, but if they are really good, 
spyware may replace legit system file and it will need a tool to check 
if it is really spyware or the legit file!

Probably legit programs (could still be replaced by spyware!):

HKLM...Run 	mobsync.exe /logon.  Sync Manager
KHCU...Run	ctfmon.  Office2003 text2speech [potentially key logger]  




Additional crap that is loaded somehow...

C:\Program Files\Common Files\Real\Update_OB\
apperently lot of .dll and .exe which somehow get executed
rnms3270.dll is the realone messanger center crap that do lot of pop up messageging ads.  Delete or rename them!

---

Internet MIME programs (may load all the time)
C:\winnt\Downloaded Program Files\ 
Each control has its own entry, right click and then choose remove
(eg, will see DBFullInst Control for the stupid SpyWare program).

---

SpyBot AntiSpyware program has tool that list all program that will be loaded up at boot time and allow single click disactivation.

Hackish way to reset password

At least for Win 7. Idea is to replace the sethc.exe program, which is what accessibility invokes, and replace it with cmd.exe then during login, press shift 5 times or alt sh prtSc to invoke the accessibilty program, get dos prompt instead, and issue command
net user geek newPassword
detailed steps are listed in http://www.howtogeek.com/96630/how-to-reset-your-forgotten-windows-password-the-easy-way/
(replace sethc.exe when done. or maybe not... nice quick shortcut to cmd, but perpetual back door...)

Cool SA tools

WinDirStat
Get it from sourceforge.net, a program that will collect disk stat usage (network share ok), keep track of subfolder disk usage, and also give aggregate of files type usage (eg mp3, m4a, avi, pst, zip, etc).

PDF Forge A freeware to generate PDF for windows (freeware version of Acrobat Writer).


Unixfying Windows/DOS

  1. Cygwin add a lot of standard unix tools, libraries, etc. Includes a bash shell and X Window Manager for running X-based (GUI) apps. It even has GNOME, KDE, keepassx (Qt), tetris!
      add this to PATH system variable  
      c:\cygwin\bin;c:\cygwin\sbin;c:\cygwin\usr\bin;c:\cygwin\usr\sbin;
      modern cygwin creates .bashrc in user's home dir and source that, so PATH can be setup there.
    
      A somewhat yum-like feature to add new packages, eg python:
      setup-x86_64.exe -P python
      	it still run the GUI, but then the python package is selected, 
    	so can just click next/next/next to complete.
      setup-x86_64.exe -M -P wget,curl,dog,openssh,ctorrent,openldap,nc,rsync
    	-M will skip many GUI prompt and go right into the package selection window.
    	openssh is for both client and server?
    	openldap is for the client portion only
    
      apt-cyg (not fully stable) may provide an apt-get like command interface to install packages, one at a time.
    
    	wget http://raw.github.com/transcode-open/apt-cyg/master/apt-cyg
    	chmod +x apt-cyg
    	mv apt-cyg /usr/local/bin
    
    	apt-cyg install nano
    	apt-cyg install git
    	apt-cyg install ca-certificates
    
    	
    
  2. MKS Toolkit. This actually pre-date cygwin, but this is moneyware.
  3. SFU Microsoft Services for Unix. Add NFS client and server, telnet server, and other tools to bridge Unix and Windows machines. In the same manner that Samba teaches Unix to talk Windows, SFU teaches Windows to talk Unix.


[Doc URL: http://psg.ask-margo.com/dos.html]
(cc) Tin Ho. See main page for copyright info.


"ting"
"ting"