Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

See http://technet.microsoft.com/en-us/library/ff715408.aspx for FirstLogonCommand, how do I specify a CommandLine for the OS boot drive and not just use "C:" like the examples do. The OS boot drive might not be "C:".

Update: I am using C++ to write the XML and the program that will run is also written in C++.

share|improve this question
    
I am not entirely sure what you are after (I am not a Windows person), but the %SystemDrive% environment variable is set to the operating system drive, and should work in most commands. –  cyberx86 Feb 18 '12 at 8:23
    
@unixman83: I didn't downvote, but please see my answer. This is not really a script-question. This is about running post-install commands during an automated install of Vista and later Windows versions. –  Tonny Feb 18 '12 at 9:42
1  
@John Gardeniers: That they are expended at that point may be obvious to you, but I have never been able to get that confirmed anywhere. As for the scripting... What I intended to say, but didn't formulate well enough, is that when you pass unexpanded env-var's from one program to another (as happens here) it totally depends on the programs/environment whether or not they will be expanded. –  Tonny Feb 18 '12 at 11:39
1  
@Harry, while that is perfectly true, my comment was was made in the context of the question being asked here, in which instance cmd.exe is involved. –  John Gardeniers Feb 21 '12 at 4:24
1  
@JohnGardeniers: I believe you, but I think Tonny is asking for a reference. That is, how do you know that the FirstLogonCommand option uses cmd.exe? –  Harry Johnston Feb 21 '12 at 21:27

2 Answers 2

up vote 1 down vote accepted

Interesting question. No help from Microsoft (as usual).

%SystemDrive% environment var is normally what you would use in scripts and such, but this is not really a script.

Frankly I have no idea if it will work in this particular fringe case.

If the system passes whatever is in the XML straight to cmd.exe it will work.

If it goes, with out expanding the environment var, directly into the exec() call of the Windows-API it is doubtful it will work.

You will just have to try it. As there is no visual feedback while this runs I recommend you run something that writes a logfile in a known location so you can be certain whether it worked or not.

Another solution comes to mind: Assuming that, while this runs, the current drive IS the OS drive you might just get away without specifying the drive at all. Just use the full part from the top of the drive without the drive-letter and colon.

E.g: \synccommands\run1.exe

Let us know how this turned out. I for one am interested if one of those solutions works and I don't have the time nor the equipment to experiment myself.

share|improve this answer
1  
If Windows Setup doesn't expand environment variables, just explicitly invoke cmd.exe: cmd /c %SystemDrive%\path\program.exe –  Harry Johnston Feb 21 '12 at 3:31

The %SystemDrive% environment variable is set to the operating system drive in Windows and can be replaced into most commands.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.