Archive

Archive for September, 2008

Robocopy – Best Damn Windows Comand line Copy Util!

September 29, 2008 scripthacks Leave a comment

I’m a huge fan of the windows robocopy program.  It allows you to perform migrations and copies between servers. Recurvsive copy capabilities are included as well as copies based on file archive bit settings.

Basic Robocopy syntax:

robocopy <source dir> <destination dir> <file> <options>

Copy 1 file:

robocopy c:\test\ d:\test move-this-file.txt /z /r:1 /w:1 /v /eta /e /L

/z = copy the file in restartable mode… if the file copy breaks it will just pick up where it left off.

/r:1= When copying a large number of files and or folders I always set the retry count to be really low. That way if it gets hung up on a file it just skips it.

/w:1= Same as /r except this pertains to the wait timeout. ie. if there is a ton of latency the file is skipped.

/v = show output on screen during the copy

/eta = show me how long it expects the copy to take

/e = recursively copy all sub folders and files including empy ones empty directories.

/L ALWAYS use /L before running any robocopy script or command. It will show you what is going to be copied by the command being run.

Robocopy is included in the Windows 2000+ Resource pack which can be download in my Utilities link found at the top of the page.

RDP – Force Console Access

September 29, 2008 scripthacks 1 comment

With large managed corporate environments I’ve noticed that many people don’t properly log out of active RDP sessions.  The result of this scenario is that all licensed RDP connections (default = 2) are used up and Admins cannot connect to a server without either somehow booting someone from the box or gaining console access.

There is a simple and easy resolution to this issue.  By using windows built in tools you can force console access to any server running RDP.  Windows provides the utility called mstsc which can be run from a command window with a force parameter.  This will either give you a 3rd connection to the server (console) or give you the option of booting off a user who has been idle or disconnected from the server for an extended period of time.

Bottom line… use this command! :)
mstsc -v:<server name> /F -console

NOTE: This command no longer works… refer to this post for the updated syntax.

Fix – iPhone stuck at pineapple boot screen

September 20, 2008 scripthacks 11 comments

Symptom: iPhone won’t boot, hangs at pineapple boot screen
Fix: Put iPhone in DFU mode.

  1. Launch iTunes
  2. Connect iPhone to computer via USB cable
  3. Shut iPhone off (press and hold sleep/power button)
  4. Reset iPhone by pressing & holding both the power button and home button (Note Screen will be blank)
  5. Release power button after 10 seconds
iTunes will now recognize the iPhone in DFU mode. It will then give you the option of restoring it.
Restoring an alternative .ips file within iTunes.
  1. Launch iTunes
  2. Connect your iPhone
  3. On the iPhone summary screen press and hold Shift and press Restore.
  4. You will be given the option of selecting your own .ipsw file.
By default iTunes stores .ipsw files in this folder:
C:Documents and SettingsAdministratorApplication DataApple ComputeriTunesiPhone Software Updates
or
C:Documents and Settings<user account name>Application DataApple ComputeriTunesiPhone Software Updates

iPhone 2.1 – Feature List

September 19, 2008 scripthacks 1 comment

Performance (Only Data is now backed up & re-copied down)
 Faster Backup times (confirmed)
 Faster Update times (confirmed)

Music
 Playlists & Songs now include the album name & artist shown bellow the track name
 Genius (song search now included)
 Added categories
    - Compilations
    - Composers
    - Audiobooks
 Podcasts (not sure if this is new… but still really cool)
- Album art work for each individual track displayed
- Ability to skip through each track found within podcast  

Parental Controls
 Restrict content (parental controls)

Reset iPhone back to factory defaults
 Reset All Settings
 Erase All Content and Settings (Full Data Erase)
 Reset Network Settings
 Reset Keyboard Dictionary
 Reset Home Screen Layout
 Reset Location Warnings

Passcode Lock
 Erase ALL data after 10 failed passcode attempts

Categories: 2.1, iPhone Tags: , ,

Disable – Windows Instant Messenger

September 17, 2008 scripthacks Leave a comment

For the longest time I’ve slacked about disabling Windows Instant Messenger from loading when XP boots.  Today I finally stopped slacking and found the necessary Registry tweaks to make the little b*stard stop loading at boot. 

Fix: Using Regedit add the following Registry key & reboot.
[HKEY_LOCAL_MACHINESOFTWAREPoliciesMicrosoftMessengerClient]
"PreventRun"=dword:00000001

Step by Step Instructions:

  1. Launch regedit Start -> run type regedit
  2. Drill down to the Microsoft Folder found within HKEY_LOCAL_MACHINESOFTWAREPolicies
  3. Create a Messenger folder if one does not already exist (Right click in right panel and select New Key)
  4. Create a Client folder if one does not already exist (Right click in right panel and select New Key)
  5. Right click right panel and select New -> DWORD and name it PreventRun
  6. Right click PreventRun and modify it setting it to 1
  7. Reboot Windows
Categories: Windows Tags: , ,

Google Chrome – Mouse Scroll Issue

September 17, 2008 scripthacks 4 comments

After installing Google Chrome on my home PC I noticed that I could only scroll down with my mouse wheel.  When attempting to scroll up the browser did nothing.  This seemed strange… since I could scroll up and down using the mouse wheel in other browsers (Safari, Firefox, IE).  

This issue has been extensively discussed in forums across the internet.  I found my fix in this sites discussion -> Solution to Google Chrome Mouse Scroll Issue

I ended up having to upgrade my mouse drivers from Microsofts site.  I have a crazy old Microsoft Wheel Mouse Optical which is both cheap and effective.  

Updated Microsoft mouse drivers can be downloaded from here: Microsoft Driver Download Site

Not only did upgrading the driver fix the issue, it also gave my mouse additional functionality. (Macro creation, better wheel manipulation capabilities etc.) 

Google Chrome can be downloaded here: Download Google Chrome!

Grep equivalent for Windows (String Parsing)

September 16, 2008 scripthacks Leave a comment

The built in windows command FindStr mirrors the capabilities of the Unix command Grep.

Findstr /?
FINDSTR [/B] [/E] [/L] [/R] [/S] [/I] [/X] [/V] [/N] [/M] [/O] [/P] [/F:file]
        [/C:string] [/G:file] [/D:dir list] [/A:color attributes] [/OFF[LINE]]
        strings [[drive:][path]filename[ ...]]
  /B         Matches pattern if at the beginning of a line.
  /E         Matches pattern if at the end of a line.
  /L         Uses search strings literally.
  /R         Uses search strings as regular expressions.
  /S         Searches for matching files in the current directory and all
             subdirectories.
  /I         Specifies that the search is not to be case-sensitive.
  /X         Prints lines that match exactly.
  /V         Prints only lines that do not contain a match.
  /N         Prints the line number before each line that matches.
  /M         Prints only the filename if a file contains a match.
  /O         Prints character offset before each matching line.
  /P         Skip files with non-printable characters.
  /OFF[LINE] Do not skip files with offline attribute set.
  /A:attr    Specifies color attribute with two hex digits. See “color /?”
  /F:file    Reads file list from the specified file(/ stands for console).
  /C:string  Uses specified string as a literal search string.
  /G:file    Gets search strings from the specified file(/ stands for console).
  /D:dir     Search a semicolon delimited list of directories
  strings    Text to be searched for.
  [drive:][path]filename Specifies a file or files to search.

Example of using Findstr to search for multiple strings in succession within a log file.
findstr “ERROR Caused Fail” c:logslog.log

This command will search for the String ERROR then Caused, and Fail while parsing down a file. So if the file looked like this:
Line1: Error Script Failed
Line2: test1
Line4: Caused by process down
Line5: test2
Line6: Error2

The FindStr output would look like this:
Error Script Failed
Caused by Process down
Error2

Windows Host Up Time

September 16, 2008 scripthacks Leave a comment

Find out when a Windows host was last restarted using native windows commands.  

Run net stats srv
Server Statistics for \LAP1

Statistics since 9/16/2008 9:14 AM

Sessions accepted 1
Sessions timed-out 0
Sessions errored-out 0

Kilobytes sent 0
Kilobytes received 0

Mean response time (msec) 0

System errors 0
Permission violations 0
Password violations 0

Files accessed 0
Communication devices accessed 0
Print jobs spooled 0

Times buffers exhausted

Big buffers 0
Request buffers 0

 

The command completed successfully.

Pipe to findstr to filter out unecessary stats.

net stats srv | findstr “since”
Statistics since 9/16/2008 9:14 AM

Windows Scripting Tools

September 16, 2008 scripthacks Leave a comment

Windows Services – Query Current Status

September 15, 2008 scripthacks Leave a comment

Find the current status of a service running on a server or windows workstation/laptop. 

sc query <Service Name> | findstr STATE

To find a list of all installed services launch the services computer management window by running Services.msc or by launching start -> programs -> Administrative Tools -> Services 

  1. Right click the service in question
  2. The Service Name will be the name that you reference in your service query. 
Example Service: Indexing Service = CiSvc
Example Status Output: sc query CiSvc | findstr STATE
Output:                          STATE              : 1  STOPPED
Categories: Uncategorized Tags: , , ,