Batch file question
Hello Technet, I am trying to create a batch file that will autodetect the drive letter the HDD is assigned and run imagex with the appropriate drive letters. So far, I have this: @echo offif drive=e: then e:\imagex /apply e:\images\ud32test.wim 1 c:\ if drive=f: then f:\imagex /apply f:\images\ud32test.wim 1 c:\ if drive=g: then g:\imagex /apply g:\images\ud32test.wim 1 c:\ c:\windows\system32\bcdboot c:\windows X:\windows\system32\bcdboot c:\windows Am I using the if then statements properly or will this fail out? Any and all help is greatly appreciated! Please remember to click "Mark as Answer" on the post that helps you, and to click "Unmark as Answer" if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
March 12th, 2013 3:24pm

Sorry, this won't work. Try this variant (untested): @echo off set Drive= for %%a in (E: F: G:) do if exist %%a\ImageX set Drive=%%a if "%Drive%"=="" echo Drive not found & goto :eof echo The drive letter is %Drive% %Drive%\imagex /apply %Drive%\images\ud32test.wim 1 c:\
Free Windows Admin Tool Kit Click here and download it now
March 12th, 2013 3:40pm

Sorry, this won't work. Try this variant (untested): @echo off set Drive= for %%a in (E: F: G:) do if exist %%a\ImageX set Drive=%%a if "%Drive%"=="" echo Drive not found & goto :eof echo The drive letter is %Drive% %Drive%\imagex /apply %Drive%\images\ud32test.wim 1 c:\
March 12th, 2013 10:32pm

Hi, Hows everything going? Please feel free to give me any update. Thank you for your cooperation. Regards, Vincent Wang If you have any feedback on our support, please click hereVincent Wang TechNet Community Support
Free Windows Admin Tool Kit Click here and download it now
March 14th, 2013 3:50am

Well, PART of it worked. It came back with Drive not found...so part of it is working. Any thoughts on how to fix it? Apparently my batch file programming needs work BUT I did think of another way to do it. Could I use if then else statements and just label the 3 or 4 drive letters that it could be? Let me know what you think. Edit: After examining the coding, I found some inconsistences and here is how I have corrected it...but it's still untested. @echo off set Drive= for %%a in (E: F: G:) do if exist %%a\ImageX.exe set Drive=%%a if "%Drive%"=="" echo Drive not found & goto :eof echo The drive letter is %Drive% %Drive%\imagex /apply %Drive%\images\ud32test.wim 1 c:\ I think the extension is going to make it work, but again...I haven't tested it thought I am getting to that point right now. I will let you know what happens. Please remember to click "Mark as Answer" on the post that helps you, and to click "Unmark as Answer" if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
March 14th, 2013 1:01pm

Verified, adding the .exe extension to imagex made it work perfectly. Thanks for the help!Please remember to click "Mark as Answer" on the post that helps you, and to click "Unmark as Answer" if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
Free Windows Admin Tool Kit Click here and download it now
March 14th, 2013 2:56pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics