How to have Userprofile variable in bks file or convert text file containing variables to bks using a batch script?

Posted on 2009-12-27
Medium Priority
Last Modified: 2012-05-08
We  have created a batch script to run nt backup to backup our field computers. We had bks file with variable userprofile (%userprofile%) but nt backup would not recognize it. Is it possible to have any variables in bks file which is unicode format so that Nt backup recognizes it.Or I need to find a way to using a batch script to take a text file containing locations with variables to a local location and then convert convert the file to Unicode. The reason we want text file is the capability to add more location if needed.

Question by:dakoit
LVL 59

Accepted Solution

Bill Prew earned 1900 total points
ID: 26128389
This seemed to work for me.  Save the attached BAT script as a file, let's say CHGBKS.BAT.  Then run as follows from a command line.

CMD /U /C CHGBKS.BAT inputfile.txt outputfile.bks

The idea here is that the CMD /U option forces unicode output from the BAT file executed.  In my batch file I just process the inputfile, replace the %USERPROFILE% string in the file with the current environment variable, and then write it out again to outputfile.

@echo off
setlocal EnableDelayedExpansion
setlocal EnableExtensions
if exist %2 del %2
for /f "tokens=*" %%A in ('type %1') do (
  set Temp=%%A
  echo !Temp!

Open in new window

LVL 71

Assisted Solution

Qlemo earned 100 total points
ID: 26128564
That method is unsafe, as some chars might be  converted. I tested with
%UserProfile%\My Docs
Another one

and the second line was converted to
That might be not important, as long as noone is using Unicode folder names in the BKS file.

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

MS Outlook undoubtedly is the most widely used email client.Its user-friendliness, cost effectiveness, and availability with Microsoft Office Suite make it the most popular email application.  Its compatibility with Microsoft applications like Exch…
Most folks would know the basics of how Dropbox works, so that’s not the purpose of this article. Security is what it’s all about, so here I’ll share how I choose to secure my Dropbox Account and the Data it contains.
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question