?
Solved

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
2
Medium Priority
?
584 Views
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.

thanks
Andy
0
Comment
Question by:dakoit
2 Comments
 
LVL 59

Accepted Solution

by:
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.

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

Open in new window

0
 
LVL 71

Assisted Solution

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

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

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