Search found 319 matches

by ghostmachine4
31 Oct 2014 22:25
Forum: DOS Batch Forum
Topic: Checking for several different strings in a variable
Replies: 14
Views: 14515

Re: Checking for several different strings in a variable


I'm not sure how to use this... can I call it from a batch script? Either way, thanks for the effort :)


save as a file and on command line

Code: Select all

cscript //nolog myscript.vbs myFileToSearch.txt
by ghostmachine4
31 Oct 2014 21:52
Forum: DOS Batch Forum
Topic: Extract only the last word from a string
Replies: 5
Views: 11297

Re: Extract only the last word from a string

vbscript, using arrays

Code: Select all

myString = "one two three four five"
myArray = Split(myString)
WScript.Echo myArray( UBound(myArray) )
by ghostmachine4
31 Oct 2014 21:41
Forum: DOS Batch Forum
Topic: Checking for several different strings in a variable
Replies: 14
Views: 14515

Re: Checking for several different strings in a variable

vbscript comes with regular expression. Set objFSO=CreateObject("Scripting.FileSystemObject") Set regex = New RegExp With regex .Pattern = "example|this.*that" .IgnoreCase = True .Global = False End With inputFile = WScript.Arguments(0) Set objFile = objFSO.OpenTextFile(inputFile...
by ghostmachine4
31 Oct 2014 20:46
Forum: DOS Batch Forum
Topic: Remove character at begin of line
Replies: 9
Views: 9373

Re: Remove character at begin of line

vbscript Set objFSO=CreateObject("Scripting.FileSystemObject") inputFile = WScript.Arguments(0) Set objFile = objFSO.OpenTextFile(inputFile) Do Until objFile.AtEndOfStream strNextLine = objFile.ReadLine Do While Mid(strNextLine,1,1) = "0" Or Mid(strNextLine,1,1) = " " s...
by ghostmachine4
24 Dec 2013 05:35
Forum: DOS Batch Forum
Topic: Batch Wake-On-Lan
Replies: 15
Views: 23180

Re: Batch Wake-On-Lan

No, you misunderstood me. Is there any way you can send WOL packets through batch without third-party software? To send WOL packets programmatically you need the UDP protocol and for that you need to program using a language that support the UDP packet programming. If you really cannot use any othe...
by ghostmachine4
24 Dec 2013 05:05
Forum: DOS Batch Forum
Topic: Batch Wake-On-Lan
Replies: 15
Views: 23180

Re: Batch Wake-On-Lan

Is there any way to implement WOL functionality in batch without the need of third-party software? you can do that with a vb script. I personally have not tried it but you can download the code here . save it as something.vbs , edit the settings to your liking and execute c:\> cscript //nologo some...
by ghostmachine4
19 Dec 2013 01:22
Forum: DOS Batch Forum
Topic: CAN A BATCH FILE CAPABLE TO DO THE BELOW
Replies: 5
Views: 7848

Re: CAN A BATCH FILE CAPABLE TO DO THE BELOW

do we have any options of doing it without a any external application installation( so no JDK , VB etc) thanks Ashok vbscript (or rather the engine) comes installed with most versions of Windows unless its purposely turned off due to various reasons, eg security reasons. You do not need to download...
by ghostmachine4
19 Dec 2013 00:06
Forum: DOS Batch Forum
Topic: Batch help to replace 1 line by number in a text file
Replies: 17
Views: 17540

Re: Batch help to replace 1 line by number in a text file

Try this code: It uses a helper batch file called `repl.bat` from - m wow, jscript. so unconventional. You may smile Both repl.bat and findrepl.bat are native solutions to much of what SED and GREP can do, respectively. what i mean by "unconventional" is that usually the people will just ...
by ghostmachine4
18 Dec 2013 23:53
Forum: DOS Batch Forum
Topic: CAN A BATCH FILE CAPABLE TO DO THE BELOW
Replies: 5
Views: 7848

Re: CAN A BATCH FILE CAPABLE TO DO THE BELOW

you can use a vbscript Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFolder = objFSO.GetFolder("C:\myFolder") strTo= "recipient@mail.com" strFrom="sender@mail.com" strSubject="Subject of mail" strAccountID="user" strPasswor...
by ghostmachine4
18 Dec 2013 23:10
Forum: DOS Batch Forum
Topic: Batch help to replace 1 line by number in a text file
Replies: 17
Views: 17540

Re: Batch help to replace 1 line by number in a text file

foxidrive wrote:Try this code:
It uses a helper batch file called `repl.bat` from - https://www.dropbox.com/s/qidqwztmetbvklt/repl.bat

wow, jscript. so unconventional. :D
by ghostmachine4
18 Dec 2013 22:11
Forum: DOS Batch Forum
Topic: Batch help to replace 1 line by number in a text file
Replies: 17
Views: 17540

Re: Batch help to replace 1 line by number in a text file

vbscript solution. Dim objFSO,objFile,line Const ForReading=1, ForWriting=2 Set objFSO= CreateObject("Scripting.FileSystemObject") Set objFileRead = objFSO.OpenTextFile("C:\original.txt", 1) Set objFileWrite = objFSO.CreateTextFile("C:\copyoriginal.txt") Do Until objFil...
by ghostmachine4
30 Aug 2011 20:41
Forum: DOS Batch Forum
Topic: Insert text into column b csv file
Replies: 25
Views: 32976

Re: Insert text into column b csv file

Ok... I did not understand, does this script need to be inserted before the current commands are run? I guess I am not understanding this script. When I execute it as a batch file I get several errors... Could you give me a little example of how I should be using this. Thank you very much for your ...
by ghostmachine4
30 Aug 2011 07:22
Forum: DOS Batch Forum
Topic: Insert text into column b csv file
Replies: 25
Views: 32976

Re: Insert text into column b csv file

Thanks for the reply... I need it in a batch format. Other people will be accessing the file placed on there desktops. The CSV file has changing dates in column A. When they input a line it needs to line up with the dates already in file on the network (line B1, B2, B3 etc...) They may not have pow...
by ghostmachine4
29 Aug 2011 22:08
Forum: DOS Batch Forum
Topic: replace a string in a file and then save file with new name
Replies: 4
Views: 6924

Re: replace a string in a file and then save file with new n

[quote="Ocalabob"] ::Use SED to replace some text. type $$$Gerry.txt |SED "s/men/men and women/g" |SED "s/Country./State./g">$$$Gerry_final.txt No need to use type, since sed takes in a file as argument. And you can combine sed commands together sed "s/men/blah bla...
by ghostmachine4
29 Aug 2011 20:05
Forum: DOS Batch Forum
Topic: Insert text into column b csv file
Replies: 25
Views: 32976

Re: Insert text into column b csv file

Use something better to process files instead of batch.. If you want native solution, you can use vbscript (or powershell), Set objFS = CreateObject( "Scripting.FileSystemObject" ) strFile = WScript.Arguments(0) Set objFile = objFS.OpenTextFile(strFile) Do Until objFile.AtEndOfStream strLi...