/build/static/layout/Breadcrumb_cap_w.png

WiseScript - Need a script for replacing a string

Hello there.

I hope you can help me.

I need to replace a string in a batch file with a value in INSTALLDIR

The build-in function "Insert Line into Text file" replace the whole line instead of the selected string.

Any1 of you made a custom script to do this kind of operation ?

thanks

0 Comments   [ + ] Show comments

Answers (4)

Posted by: aogilmor 17 years ago
9th Degree Black Belt
0
there are some samples in the \WiseScript Editor\Samples directory, have you checked those out?
Posted by: BuRsT 17 years ago
Senior Yellow Belt
0
Yes I already look at theses samples and none of them can do what I need
Posted by: aogilmor 17 years ago
9th Degree Black Belt
0
look at the textfile.wse, it'll do that with a little tweaking.

if that doesn't work for you, vbscript has some search/replace capability, thogh it can be a little cumbersome.
Posted by: Secondlaw 17 years ago
Third Degree Blue Belt
0
You can cut and paste the below code into your script to see what I did. The purpose of the following script was used to create a batch file which would run a set of commands, then output to a logfile %username%.log.

If you need more insight into this, please feel free to post your email address and I'll reply.


item: Remark
Text===== FLOPPY DRIVE CHECK ====
end
item: Delete File
Pathname=%TEMP%\Floptst.bat
end
item: Install File
Source=.\vbs\flpytst.vbs
Destination=%TEMP%\flpytst.vbs
Flags=0000000010000010
end
item: Insert Line into Text File
Pathname=%TEMP%\Floptst.bat
New Text=@ECHO OFF
Line Number=0
end
item: Insert Line into Text File
Pathname=%TEMP%\Floptst.bat
New Text=C:
Line Number=0
end
item: Insert Line into Text File
Pathname=%TEMP%\Floptst.bat
New Text=CD \
Line Number=0
end
item: Insert Line into Text File
Pathname=%TEMP%\Floptst.bat
New Text=CD %TEMP%
Line Number=0
end
item: Insert Line into Text File
Pathname=%TEMP%\Floptst.bat
New Text=chkdsk a: >%TEMP%\%USERNAME%-flop.LOG
Line Number=0
end
breakpoint item: Insert Line into Text File
Pathname=%TEMP%\Floptst.bat
New Text=cscript flpytst.vbs >>%TEMP%\%USERNAME%-flop.LOG
Line Number=0
end
item: Insert Line into Text File
Pathname=%TEMP%\Floptst.bat
New Text=exit
Line Number=0
end
item: Execute Program
Pathname=cmd.exe
Command Line=/c %TEMP%\floptst.bat
Default Directory=%TEMP%
Flags=00001010
end
item: Insert Line into Text File
Pathname=%TEMP%\%USERNAME%-flop.LOG
New Text=
Search Text=Microsoft (R) Windows Script
Line Number=0
Flags=00101010
end
item: Insert Line into Text File
Pathname=%TEMP%\%USERNAME%-flop.LOG
New Text=[FLOPPY INFO]
Search Text=Copyright (C) Microsoft
Line Number=1
Flags=00001010
end
item: Insert Line into Text File
Pathname=%TEMP%\%USERNAME%.LOG
New Text=
Search Text=Status=
Line Number=0
Flags=00110010
end
item: Remark
Text===== END OF FLOPPY CHECK ====
end
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ