Category Archives: Tools

%SystemRoot%System32 Secrets: compact & convert

I’ve been quite busy for some time, so there is a quick run over two utilities: compact and convert. The first one can be used sometimes while the second, I think, has almost died out. Let’s take a look on them.

compact

Remember cipher? The same stuff: cipher deals with encryption, this one – with compression on an NTFS volume. You need to script it or find it boring to use all that GUI? It’s for you. But seriously: do many people use it? I don’t like the feature, actually. But anyway, if you need it, you get it.

convert

This command I haven’t used for years. Really, who has a file system which can be converted to NTFS now? Probably, on some thumb drive. Yet it was very useful back then, in time when we all were moving from windows 9x to Windows 2000 or XP. I used it quite often, so when I found it still placed on my W7 system, I decided to honor it even if it is worthless now. BTW, probably, it isn’t? Then tell me =)

Advertisements

%SystemRoot%system32 secrets: cipher

Next command in my list is what you never remember about unless user comes in with a cry: “I’ve reset my password and now all my EFS-encrypted files are gone!!!”. Are you familiar with the situation? I am not, fortunately, but I heard some related horror stories. Backup the encryption keys is the key. And updating of keys on the files. And creating of recovery keys. And backing up the encryption keys. All that the utility in the question can do for you.

There are plenty of articles about the actions described above. But when I tried to look at the utility’s description more closely, I found one new function: cipher with arguments “/W” and a folder will remove all data from unused disk space on the volume where the folder is placed. What it is doing is:

1) Creating folder EFSTMPWP on the volume:

2) Creating there a temp file (or several, according to some sources)

image

3) Writing there zeros, then ones, and polishes it with some random values:

image

It does each step until the whole disk is filled up and then repeats:

image

image

image

Of course it is quite time consuming, especially on large volumes. But if I was the person to design the command, I’d rather made it to write not just zeros and ones, but just encrypt every free cluster with a random key. Luckily it wasn’t me, so it is not even more long procedure 😉

The command asks you to close all the applications to make the effort as effective as it is possible, mostly to eliminate all the temp files with data in them.

Further reading:

cipher /?

http://technet.microsoft.com/en-us/library/cc771346(WS.10).aspx

http://support.microsoft.com/kb/295680

http://support.microsoft.com/kb/814599

BITS Transfer PowerShell cmdlets

One friend of mine told me that I shouldn’t have spread knowledge about BITSAdmin command while there was the PowerShell cmdlets in place. Well, to some extent he is definitely right:

  • 1) PowerShell is better self-documented.

2) It is waaaay easier to script with.

3) It is more simple to use in some basic situations like “just give me that darn file”.

4) Many people just like PoSh.

So, the tasks I did in my post about BITSAdmin seems to be done in one command:

Start-BitsTransfer –source <URL> –destination <PathToFile>

but one need to do his homework better:

image

Seems like the module for BITS is not imported by default. Let’s correct the mistake:

image

and now we have our cmdlets:

image

So, let’s our download begin:

image

Excellent, isn’t it (it even show the progress very visually)? No, it isn’t. Because when I turned my network connection off the download was cancelled:

image

Even though it was stated that “BITS will try again” – it wouldn’t and there wasn’t any job registered with BITS. I don’t know why, actually (I hope my friend will explain it to me), but I found a “workaround”. Just add “-Asynchronous” option to the string and it will fork just fine for you although you won’t be able to see that beautiful download bar:

image

image

But even when the state changed to “Transferred”, there was only a .tmp file in my directory. Actually, when I started the command without “-Asynchronous” option, I’ve got the file immediately after the end of the transfer, but you already know that you cannot then resume the transfer if it was interrupted. Therefore, I had to complete the transfer manually:

image 

Not very big difference from what we did with BITSAdmin, I guess. And I couldn’t tell how to do is to monitor my jobs in fasion BITSAsmin /MONITOR does.

So, let’s sum it up:

1) PoSh is best for scripting

2) You can use for interactive tasks whichever command set you are used to, but remember, that BITSAdmin can be discontinued any moment

So, my best approach is, do everything I can with PoSh and monitor with BITSAdmin, until someone tells me how to do it with PoSh 😉

Check your certificate status visually

imageJust another not bad tool. If you don’t have a wildcard certificate in use, probably you have many of them and in many places.Usually such kind of system is being monitored automatically with some system (OpsMgr, nagios, custom software), but sometimes you just need to get an overview of what’s happening right now. In this case you can use some report if you have one suitable, or write your own report, or use the following tool: VerifySSLSertificate.It’s small, robust and have just several but essential functions and settings. You can save and load a list of servers to check, save a certificate from a server and set a warning threshold. That’s it. Do you need more to get a brief overview? I doubt it, to be honest, it is quite visual:

image 

So, thanks you, Chris Blankenship, for this tool and several others.

%SystemRoot%system32 secrets: Choice

We won’t assess the next three commands – chglogon, chgport and chguser – because they are all replaced by change. Therefore the next candidate in the race is

choice

While not being helpful alone it could be useful in batch scripts. Those can be actually very powerful, still I like PowerShell more because it allows me to do stupid things faster and of more quality. But just in case you want to do some *.bat files with not linear logic depending on a user’s input, you can use it. For example, you can ask something like this:

image

=))) Moreover, you can set default choice and auto accept it after some time:

image

I haven’t pressed a key here, but the command substituted “b” after 5 seconds of waiting.

Getting out the user’s choice is not perfectly straightforward. It doesn’t return the result as I’m used to. It put the result into %ERRORLEVEL% variable. It is not a big deal, but… I’d rather use PowerShell for it, really. Nevertheless, if you are still addicted to DOS shell, it is sometimes your “choice” 😉

Migrate scheduled tasks from 2003 to 2008

Well, the time has come for me to learn at last syntax for schtasks what I was reluctant to do. Some time you have to migrate a task or a bunch of them from one computer to another. In my case it was even more “interesting” task: migrate some tasks from Windows Server 2003 box to Windows 2008 R2. If you have only one it is no problem to move it manually, but what if there are many of them? Here it is: the moment of schtasks’ triumph! =)

What it can do for us is to export 2003’s tasks into an XML file. Suppose we have task “Command Prompt” which launches cmd.exe once:

image

image

image

Now let’s use our secret weapon (run it from 2008 box):

image

In Task.xml we now have the following content:

   1: <?xml version="1.0" encoding="utf-16"?>

   2: <Task version="1.1" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">

   3:   <RegistrationInfo>

   4:     <Author>trofimov</Author>

   5:   </RegistrationInfo>

   6:   <Triggers>

   7:     <TimeTrigger>

   8:       <Enabled>true</Enabled>

   9:       <StartBoundary>2011-04-10T23:43:00</StartBoundary>

  10:     </TimeTrigger>

  11:   </Triggers>

  12:   <Settings>

  13:     <Enabled>true</Enabled>

  14:     <DeleteExpiredTaskAfter>PT0S</DeleteExpiredTaskAfter>

  15:     <ExecutionTimeLimit>PT259200S</ExecutionTimeLimit>

  16:     <Hidden>false</Hidden>

  17:     <WakeToRun>false</WakeToRun>

  18:     <DisallowStartIfOnBatteries>true</DisallowStartIfOnBatteries>

  19:     <StopIfGoingOnBatteries>true</StopIfGoingOnBatteries>

  20:     <RunOnlyIfIdle>false</RunOnlyIfIdle>

  21:     <Priority>5</Priority>

  22:     <IdleSettings>

  23:       <Duration>PT600S</Duration>

  24:       <WaitTimeout>PT3600S</WaitTimeout>

  25:       <StopOnIdleEnd>false</StopOnIdleEnd>

  26:       <RestartOnIdle>false</RestartOnIdle>

  27:     </IdleSettings>

  28:   </Settings>

  29:   <Principals>

  30:     <Principal>

  31:       <UserId>System</UserId>

  32:     </Principal>

  33:   </Principals>

  34:   <Actions>

  35:     <Exec>

  36:       <Command>C:WINDOWSsystem32cmd.exe</Command>

  37:       <WorkingDirectory>C:WINDOWSsystem32</WorkingDirectory>

  38:     </Exec>

  39:   </Actions>

  40: </Task>

which we can now import to our W2008R2 box with schtasks or even through GUI:

image

image

image

Of course, doing that with schtasks is more efficient way to import more than one task, but GUI is much more spectacular 😉

%System%System32 secrets: change

CLIAnother old-timer here. I cannot remember when I last used it, but I guess it still can be useful in a number of situations. For example I used to use it to install new software on a terminal server or to cease users logins to it. Now I usually don’t touch terminal servers and as far as I know they have other means to complete these tasks. Anyway, Windows 2003 is still in place and we still have the command around.

It can the following:

 

  • Change logon setting: we can turn new logons to the TS. Just change logon disable.
  • Change port mappings. I haven’t use it at all and I hope you won’t have to either, because KB article says: “Changes the COM port mappings to be compatible with DOS applications”. No way I want be anywhere near this stuff anymore =)
  • Prepare a TS for installation of a software. .ini files mapping and all that stuff. To install some software you need to change user install and you have to change user execute.

And this is all it can… But I remember what wonderful bugs you could get in case you didn’t know the command…

The only thing I don’t know how to explain is why it is still present on Windows 7? Does anyone know the answer? =)))