Video Screencast Help
Search Video Help Close Back
to help
New in the Rewards Catalog: Vouchers for "Symantec Technical Specialist" and "Symantec Certified Specialist" exams.

How do you feed variable file name to GhostSrv executed in a batch file?

Updated: 21 May 2010 | 3 comments
mepauls919's picture
+1 1 Vote
Login to vote
This issue has been solved. See solution.

I'm executing ghostsrv,  via cmd file,  with the following parms:
start ghostsrv.exe C:\images\ghost.gho rstwimg -disk1 -G-sure -le -fc:\ghosterr.txt

I'm trying to replace the ghost file image name with a variable image file name,  but don't seem to have much luck.  The filename is in a text file which is used as input to a variable called parm,  for illustration purposes. 

set /P parm = <c:\filename.txt
start ghostsrv.exe %parm% rstwimg -disk1 -G-sure -le -fc:\ghosterr.txt    I have also tried %parm and %%parm to see if there is any impact.

I never pickup the variable filename,  no matter what I try.  Is there a way to do this?  Substitute a variable for a file name?

Thanks for any and all suggestions.

discussion Filed Under:

Comments

Mark Berning's picture
10
Nov
2009
1 Vote +1
Login to vote

Well Two ways to handle

Well Two ways to handle this:
1) Don't put the filename in a file and pass that as an argument of the batch file:

command line:

batchfile.cmd filename

batchfile.cmd:

set param=%1
start ghostsrv.exe %parm% rstwimg -disk1 -G-sure -le -fc:\ghosterr.txt

2) Use the FOR command to grab the filename from a file.

batchfile.cmd:

for /f %%i in (c:\filename.txt) do set param=%%i
start ghostsrv.exe %parm% rstwimg -disk1 -G-sure -le -fc:\ghosterr.txt

NOTE: for either of the above to work you must not have any spaces in the filename path.

Hope this helps

mepauls919's picture
10
Nov
2009
1 Vote +1
Login to vote

 That did the trick!  Thank

 That did the trick!  Thank you for your assistance.  I used the FOR solution because of the way the batch file was setup.  I just had to change the %parm% to %param%.  Every other solution I tried,  involving variable name,  I could not get to work.  It would never pick up the file name,  it used the session name as the filename.
Thanks again!!

Mark Berning's picture
11
Nov
2009
1 Vote +1
Login to vote

Your welcome

Your welcome.

Oops you are right the correct script should look like:

for /f %%i in (c:\filename.txt) do set parm=%%i
start ghostsrv.exe %parm% rstwimg -disk1 -G-sure -le -fc:\ghosterr.txt

If you wanted a single line batch file you could do:

for /f %%i in (c:\filename.txt) do start ghostsrv.exe %%i rstwimg -disk1 -G-sure -le -fc:\ghosterr.tx

The big difference in last one is, if there were more than one line in c:\filename.txt then it would execute the ghostsrv.exe for each line.