Tag Archives: Microsoft

(Русский) Открытие дня

Sorry, this entry is only available in Russian.

(Русский) Workaround day

Sorry, this entry is only available in Russian.

\Microsoft was unexpected at this time

I just spent two days tracking this problem down.

I received my new development machine with Windows7 x64 only a week ago. It all was just pefect – quad core CPU could compile the world in almost no time, and brand new Visual Studio 2010 was just as good as it gets. By the way, I am the Linux guy and prefer vim, automake and gcc any other IDE, so if I call Visual Studio perfect, it means something.

Neverthless, everything good has an end. Yesterday I tried to build bcp.exe tool I needed to dissect boost, and I faced very nasty and very unclear problem. I simply could not. Every time I started the build process, it would fail with the most weird message I ever seen:

\Microsoft was unexpected at this time

Well, I mentioned I am the Linux guy, but I am not a religious fanatic. I just thought that there was a problem of some sort in the boost’s build script and used another machine to build bcp.

Next day I became really concerned. I realized that I could not use “Visual Studio Prompt” from VS 2010 and VS 2008. Every time I tried to start them, they would have that message about unexpected microsoft on them; and environment variables were not set. So I could not build anything! Sadly, this was rather a major problem for me as we had quite a few makefile projects and not being able to set the correct environment for build process was that kind of present I could happily live without.

I spent next four hours to find that this or similar problem was already mentioned several times; but nobody offered a solution that would work and nobody explained what was causing that. Some said that Windows SDK installation could break the batch file vcvars32.bat; some thought there was a bug in the batch file itself. Strangely, it all worked perfectly on the the neighbor’s machine. I even compared the files and found no difference at all.

The solution came at the end of the day when all my hopes were gone. One guy mentioned that the problem was caused by the parentheses in vcvars32.bat:

@if not "%WindowsSdkDir%" == "" (
	@set "PATH=%WindowsSdkDir%bin\NETFX 4.0 Tools;%WindowsSdkDir%bin;%PATH%"
	@set "INCLUDE=%WindowsSdkDir%include;%INCLUDE%"
	@set "LIB=%WindowsSdkDir%lib;%LIB%"
)

He mentioned that as he found out, one of the directories where SDK was had braces in the name as well, and that broke the statement above completely as batch processor would find nested parentheses in the folder’s name and consider them as the end of the statement.

Needless to mention, may machine had some paths that had braces in them. C:\Program Files (x86). And, needless to mention, it is exactly where Visual Studio is installed. And it also exists in %PATH% environment variable.

By itself, it does not break the script. As I mentioned, it worked perfectly on the other machine which was the biological twin of my PC. But, what if one of the PATH’s members is encolsed in double quotes? (to check how your PATH looks like, type echo %PATH% in command prompt). I checked and that’s what I found:

c:\winutils;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;
C:\Windows\System32\WindowsPowerShell\v1.0\;
c:\Program Files (x86)Microsoft SQL Server\100\Tools\Binn\;
c:\Program Files\Microsoft SQL Server\100\Tools\Binn\;
c:\Program Files\Microsoft SQL Server\100\DTS\Binn\;
"C:\Program Files (x86)Microsoft Visual Studio 9.0\Common7\IDE\";
C:\Program Files (x86)Microsoft Team Foundation Server 2010 Power Tools\;
C:\Program Files (x86)Microsoft Team Foundation Server 2010 Power Tools\Best Practices Analyzer\;
c:\cygwin\bin

Bingo! I found that one entry of PATH was indeed enclosed in double quotes. And, not surprisingly, it had that nasty (x86) in it. It was pointing somewhere inside VS 2008 installation tree, so I think one of VS 2008 tools I have installed recently indeed screwed this up.

So, I simply removed those double quotes. Immediately after that, both VS 2010 and VS 2008 command prompts were fixed.

So, the fist thing you should do if you’re having the same problem: look at your %PATH% environment variable and check if anything is enclosed in double quotes.

Finding this just cost me two days of work, and I hope it it helps you sorting it out much faster.

\Microsoft was unexpected at this time

(Русский) Кто о чем, а я о работе

Sorry, this entry is only available in Russian.

(Русский) Студия 2010: дневник мыши, поедающей кактус

Sorry, this entry is only available in Russian.

(Русский) VS 2010: полет нормальный

Sorry, this entry is only available in Russian.

(Русский) Неортодоксальные текстовые редакторы рулят

Sorry, this entry is only available in Russian.

(Русский) Еще одна причина, почему shelves в TFS лучше не пользоваться.

Sorry, this entry is only available in Russian.

Pause for X seconds in batch file?

Everyone who ever tried to automate routine tasks in windows knows that there is no sleep() program or its analogue. At least in default windows installation.

But there is quite an unexpected workaround:

ping -n 2 127.0.0.1 > nul

will stop batch execution for 2 seconds. (Replace 2 with your number for longer pause.)

Very simple and neat. Or is it?

(Русский) Sleep в командной строке?

Sorry, this entry is only available in Russian.

0 visitors online now
0 guests, 0 bots, 0 members