XP Trick: Admin Explorer Window

by BiggAndyy on September 6th, 2011, in Troubleshooting

Windows XPA quick tip for those remaining workstations still on Windows XP.  Need to have administrator access but you are still logged in as the normal user?  Simple.

Create a desktop shortcut to CMD.EXE

Right click and select RUN AS… and select Adminsitrator

At the Command Prompt type EXPLORER and hit enter.

Presto!  You have an explorer windows with admin level rights.

Tags: , , , ,
66 views

Missing or Corrupt HAL.DLL

by BiggAndyy on July 21st, 2011, in Windows Configuration

Ever get the error message at boot “missing or corrupt HAL.DLL”?

Ever copy HAL.DLL to WINDOWS\SYSTEM32\ and get the same error at boot time?

Ever swear at the top of your lungs…

WORK!

Yup, yup, and yup.

Never fear, it is just Microsoft lying to you (once again).

More often than not the error is not with the HAL.DLL file at all but with the boot.ini file.  HAL.DLL just happens to usually be the first file windows looks for to boot with.  (BTW: HAL stands for Hardware Abstraction Layer).

To fix this it may simply be editing the boot.ini file to reflect the actual physical hardware present.  But usually it can be fixed by booting from an install CD and doing a repair console repair.  A fixboot, fixmbr, and bootcfg will get the master boot record, the boot.ini file and everything else playing nice.

Believe me, I spent 4 hours trying to make HAL.DLL work before I found out about the boot.ini and boot record problem.

Tags: , , , , , , , ,
22 views

Using BATCH to find a file on your hard drive

by BiggAndyy on July 14th, 2011, in Windows Administration

Sounds easy, find a file on your hard drive to be used in your BATCH script.  Usually you don’t need to.  Microsoft keeps fairly well the directory structure from one version to the next.  Usually.  What about files like PRNPORT.VBS and all those files in printer administration?

In Windows XP they can be buried down 4 levels, but maybe only two.  In VIST/7 maybe just 2, and in other versions if you have to deal with them, who knows if they are even there.  Let’s face it, not every IT enabled business has up to date standards, machines, and uniform OS’s throughout.

Sometimes you have to write an awful lot of code to do a simple thing, like when a network printer changes it’s IP address, the printers are not on a print server, and all the mappings on the local machines are pointing to the IP address.  Simple thing to write a script to change the IP address.

Not so much.  Remember, I don’t have access to the AD tree, even though I am an administrator.  Since I am considered an outside “contractor” by the powers that be (even though I am paid from the same pool as the general IT staff), I have much less access.  So let’s try some guerrilla administration and solve this problem, writing a script that doesn’t care where PRNPORT.VBS lives, it will find it and use it.

Here is the code I cobbled together and I think it warrants passing along:

@echo off
@CLS
::
:: Initializing variables used
::
SETLOCAL ENABLEDELAYEDEXPANSION
SETLOCAL ENABLEEXTENSIONS
SET curdr=
SET myvar=
SET targetfile=
SET diritup=
::
:: Ask for file to find.
::
SET /P targetfile=”File to look for: ”
::
:: Initialize the target file,
:: the @ is important to keep the display uncluttered
::
@SET diritup=”dir /s /B %targetfile% 2>NUL”
::
:: Find the target file
:: It can take a while on a hard drive with a lot
:: of data.  If you have a way to search faster
:: let me know.
ECHO Finding %targetfile% (This may take a few moments)…
ECHO Note this will return only the LAST file found if there
ECHO are multiple copies of the file.
set curdr=%cd%
cd\
for /f “tokens=*” %%a in (
‘%diritup%’
) do (
set myvar=%%a
)
cd\
cd %curdr%
IF “%MyVar%”==”" GOTO :FILENOTFOUND
ECHO.
ECHO Found the file found at
ECHO %myvar%
ECHO.
ENDLOCAL
Exit /b 0
:FILENOTFOUND
ECHO File Not Here.
ENDLOCAL
Exit /b 0

Wow.  That’s a lot of typing to just do this: CSCRIPT PRNPORT.VBS -T -R %OLDPORT% -H %NEWIP%

Yeah, that’s what happens when you can’t depend on where PRNPORT.VBS lives.  The script does a couple of things, first it remembers where you started the script, goes to the root of the drive, executes a DIR /B to return the file with it’s path (IMPORTANT) and finally switches back to the original directory to do whatever you want the rest of the code to do.

One trick built in, if there are multiple copies (say you type *.JPG) for the search term (this is a generic portion of the script I wrote), the only file displayed will be the last one found.  To see all of the files insert ECHO %%a in the FOR loop just after SET MYVAR=%%a

You are asking, is this really necessary?  Yeah, in order to pass a directory result to a variable WITHOUT using a temporary file, this is one way.  You could also pipe a FINDSTR on the DIR command but I have found a FOR loop to be a bit faster and a smaller hit on the performance of the machine.

Copy it and give it a try.

Tags: , , , , , , , , , ,
139 views