|
server
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How to pass parameter from a file (txt/dll) to vbs codeHi Guys,
Any idea how to pass parameter from a file (txt/dll) to vbs code? Eg: .txt/.dll file contain value that pass the variable to .vbs file so that the .vbs file can get the variable to process. -- LucasYew ------------------------------------------------------------------------ LucasYew's Profile: http://forums.techarena.in/members/76919.htm View this thread: http://forums.techarena.in/server-scripting/1177796.htmhttp://forums.techarena.in
Show quote
Hide quote
"LucasYew" <LucasYew.3s0r7b@DoNotSpam.com> wrote in message Neither a .txt nor a .dll file can generate a parameter by itself - both news:LucasYew.3s0r7b@DoNotSpam.com... > > Hi Guys, > > Any idea how to pass parameter from a file (txt/dll) to vbs code? > > Eg: > txt/.dll file contain value that pass the variable to .vbs file so > that the .vbs file can get the variable to process. > > > -- > LucasYew > ------------------------------------------------------------------------ > LucasYew's Profile: http://forums.techarena.in/members/76919.htm > View this thread: http://forums.techarena.in/server-scripting/1177796.htm > > http://forums.techarena.in must to be invoked by some other program. You need to say what program this is. You also need to clarify if you want to pass the console output generated by the unknown program to the VB Script file. Are you talking about a single line of text? Multiple lines? Hi Pegasus,
There is a fix value save in .txt/.dll file then the value is pass over to .vbs file to process because i dont want to make changes for the value on .vbs code rather then just change the value in other place. This purpose is to easy to manage the value in future rather the seach which line in .vbs code to change the value. -- LucasYew ------------------------------------------------------------------------ LucasYew's Profile: http://forums.techarena.in/members/76919.htm View this thread: http://forums.techarena.in/server-scripting/1177796.htmhttp://forums.techarena.in "LucasYew" <LucasYew.3s257c@DoNotSpam.com> wrote in message If your reply is intended to clarify your original question then I am unable news:LucasYew.3s257c@DoNotSpam.com... > > Hi Pegasus, > There is a fix value save in .txt/.dll file then the value is pass over > to .vbs file to process because i dont want to make changes for the > value on .vbs code rather then just change the value in other place. > This purpose is to easy to manage the value in future rather the seach > which line in .vbs code to change the value. > > > -- > LucasYew to understand any of it. Sorry. Hi Pegasus,
Thanks for your reply. maybe i give you example to clear the doubt Eg: .dll file BATCHFILE=D:\ExchangeField_Extraction\ADExch_Exporting_Field.bat RCSVFILE=D:\ExchangeField_Extraction\E2K3AD_field.csv WCSVFILE=D:\ExchangeField_Extraction\E2K3AD_field1.csv Eg: .vbs file getting the value from .dll file Dim objFSO, shell Call getInfo() set shell=createobject("wscript.shell") shell.run sbatch set shell=nothing Function getInfo() Dim fso, sbatch, scsv, tstream, sline, sPara,iLen Set fso = CreateObject("Scripting.FileSystemObject") Set tstream = fso.OpenTextFile("D:\ExchangeField_Extraction\pathChanges.dll") Do Until not tstream.AtEndOfStream sline = tstream.ReadLine sPara = "BATCHFILE" iLen = Len(sPara) If Left(sline, iLen) = sPara Then sbatch = Right(sline, Len(Trim(sline)) - iLen - 1) WScript.Echo sbatch & "sub" End If sPara = "RCSVFILE" iLen = Len(sPara) If Left(sline, iLen) = sPara Then scsv = Right(sline, Len(Trim(sline)) - iLen - 1) End If sPara = "WCSVFILE" iLen = Len(sPara) If Left(sline, iLen) = sPara Then scsvW = Right(sline, Len(Trim(sline)) - iLen - 1) End If Loop tstream.Close End Function -- LucasYew ------------------------------------------------------------------------ LucasYew's Profile: http://forums.techarena.in/members/76919.htm View this thread: http://forums.techarena.in/server-scripting/1177796.htmhttp://forums.techarena.in
Show quote
Hide quote
"LucasYew" <LucasYew.3s2arb@DoNotSpam.com> wrote in message I can see a major problem with your script. It processes a .dll file, which news:LucasYew.3s2arb@DoNotSpam.com... > > Hi Pegasus, > Thanks for your reply. > > maybe i give you example to clear the doubt > > Eg: .dll file > BATCHFILE=D:\ExchangeField_Extraction\ADExch_Exporting_Field.bat > RCSVFILE=D:\ExchangeField_Extraction\E2K3AD_field.csv > WCSVFILE=D:\ExchangeField_Extraction\E2K3AD_field1.csv > > > Eg: .vbs file getting the value from .dll file > Dim objFSO, shell > Call getInfo() > set shell=createobject("wscript.shell") > shell.run sbatch > set shell=nothing > > Function getInfo() > Dim fso, sbatch, scsv, tstream, sline, sPara,iLen > Set fso = CreateObject("Scripting.FileSystemObject") > Set tstream = > fso.OpenTextFile("D:\ExchangeField_Extraction\pathChanges.dll") > > Do Until not tstream.AtEndOfStream > sline = tstream.ReadLine > sPara = "BATCHFILE" > iLen = Len(sPara) > If Left(sline, iLen) = sPara Then > sbatch = Right(sline, Len(Trim(sline)) - iLen - 1) > WScript.Echo sbatch & "sub" > End If > > sPara = "RCSVFILE" > iLen = Len(sPara) > If Left(sline, iLen) = sPara Then > scsv = Right(sline, Len(Trim(sline)) - iLen - 1) > End If > > sPara = "WCSVFILE" > iLen = Len(sPara) > If Left(sline, iLen) = sPara Then > scsvW = Right(sline, Len(Trim(sline)) - iLen - 1) > End If > Loop > tstream.Close > End Function is a binary file, the you use the ReadLine method, which is a text file method. It will read the current file up to the nearest EndOfLine marker. A ..dll may or may not have any EndOfLine markers and it is certainly not structured as a collection of lines. VB Script can be used to extract data from a binary file but not in this way. What do you actually want to get out of this .dll file? It looks like you ".dll" file is actually a text file, so you can use the
textstream methods to read it. I see a few problems causing the script to fail. First, you do not Dim scsvW in the function. Second, you Dim sbatch in the function but not in the main program. This means the value of sbatch is not visible in the main program. You should NOT Dim sbatch in the function, and instead Dim sbatch in the main program. This makes it a global variable visible everywhere. I would recommend using "Option Explicit" which would make this easier to troubleshoot. Also, you call your function as if it were a subroutine. That's OK, it works, but functions generally return a value. You could design the function to return sbatch, or whatever program should be run. Having sbatch be a global variable will also work. Finally, when you run the program it might be better to explicitly call the command processor. For example: shell.run "%comspec% /c " & sbatch However, your version should work as well. Show quoteHide quote "LucasYew" <LucasYew.3s2arb@DoNotSpam.com> wrote in message news:LucasYew.3s2arb@DoNotSpam.com... > > Hi Pegasus, > Thanks for your reply. > > maybe i give you example to clear the doubt > > Eg: .dll file > BATCHFILE=D:\ExchangeField_Extraction\ADExch_Exporting_Field.bat > RCSVFILE=D:\ExchangeField_Extraction\E2K3AD_field.csv > WCSVFILE=D:\ExchangeField_Extraction\E2K3AD_field1.csv > > > Eg: .vbs file getting the value from .dll file > Dim objFSO, shell > Call getInfo() > set shell=createobject("wscript.shell") > shell.run sbatch > set shell=nothing > > Function getInfo() > Dim fso, sbatch, scsv, tstream, sline, sPara,iLen > Set fso = CreateObject("Scripting.FileSystemObject") > Set tstream = > fso.OpenTextFile("D:\ExchangeField_Extraction\pathChanges.dll") > > Do Until not tstream.AtEndOfStream > sline = tstream.ReadLine > sPara = "BATCHFILE" > iLen = Len(sPara) > If Left(sline, iLen) = sPara Then > sbatch = Right(sline, Len(Trim(sline)) - iLen - 1) > WScript.Echo sbatch & "sub" > End If > > sPara = "RCSVFILE" > iLen = Len(sPara) > If Left(sline, iLen) = sPara Then > scsv = Right(sline, Len(Trim(sline)) - iLen - 1) > End If > > sPara = "WCSVFILE" > iLen = Len(sPara) > If Left(sline, iLen) = sPara Then > scsvW = Right(sline, Len(Trim(sline)) - iLen - 1) > End If > Loop > tstream.Close > End Function > > > -- > LucasYew > ------------------------------------------------------------------------ > LucasYew's Profile: http://forums.techarena.in/members/76919.htm > View this thread: http://forums.techarena.in/server-scripting/1177796.htm > > http://forums.techarena.in > I forgot to mention another correction. The following is in error:
Do Until not tstream.AtEndOfStream It should be: Do Until tstream.AtEndOfStream Otherwise the code reads no lines. Show quoteHide quote "Richard Mueller [MVP]" <rlmueller-nospam@ameritech.nospam.net> wrote in message news:eD7evIx0JHA.1432@TK2MSFTNGP02.phx.gbl... > It looks like you ".dll" file is actually a text file, so you can use the > textstream methods to read it. I see a few problems causing the script to > fail. First, you do not Dim scsvW in the function. Second, you Dim sbatch > in the function but not in the main program. This means the value of > sbatch is not visible in the main program. You should NOT Dim sbatch in > the function, and instead Dim sbatch in the main program. This makes it a > global variable visible everywhere. > > I would recommend using "Option Explicit" which would make this easier to > troubleshoot. Also, you call your function as if it were a subroutine. > That's OK, it works, but functions generally return a value. You could > design the function to return sbatch, or whatever program should be run. > Having sbatch be a global variable will also work. Finally, when you run > the program it might be better to explicitly call the command processor. > For example: > > shell.run "%comspec% /c " & sbatch > > However, your version should work as well. > > -- > Richard Mueller > MVP Directory Services > Hilltop Lab - http://www.rlmueller.net > -- > > "LucasYew" <LucasYew.3s2arb@DoNotSpam.com> wrote in message > news:LucasYew.3s2arb@DoNotSpam.com... >> >> Hi Pegasus, >> Thanks for your reply. >> >> maybe i give you example to clear the doubt >> >> Eg: .dll file >> BATCHFILE=D:\ExchangeField_Extraction\ADExch_Exporting_Field.bat >> RCSVFILE=D:\ExchangeField_Extraction\E2K3AD_field.csv >> WCSVFILE=D:\ExchangeField_Extraction\E2K3AD_field1.csv >> >> >> Eg: .vbs file getting the value from .dll file >> Dim objFSO, shell >> Call getInfo() >> set shell=createobject("wscript.shell") >> shell.run sbatch >> set shell=nothing >> >> Function getInfo() >> Dim fso, sbatch, scsv, tstream, sline, sPara,iLen >> Set fso = CreateObject("Scripting.FileSystemObject") >> Set tstream = >> fso.OpenTextFile("D:\ExchangeField_Extraction\pathChanges.dll") >> >> Do Until not tstream.AtEndOfStream >> sline = tstream.ReadLine >> sPara = "BATCHFILE" >> iLen = Len(sPara) >> If Left(sline, iLen) = sPara Then >> sbatch = Right(sline, Len(Trim(sline)) - iLen - 1) >> WScript.Echo sbatch & "sub" >> End If >> >> sPara = "RCSVFILE" >> iLen = Len(sPara) >> If Left(sline, iLen) = sPara Then >> scsv = Right(sline, Len(Trim(sline)) - iLen - 1) >> End If >> >> sPara = "WCSVFILE" >> iLen = Len(sPara) >> If Left(sline, iLen) = sPara Then >> scsvW = Right(sline, Len(Trim(sline)) - iLen - 1) >> End If >> Loop >> tstream.Close >> End Function >> >> >> -- >> LucasYew >> ------------------------------------------------------------------------ >> LucasYew's Profile: http://forums.techarena.in/members/76919.htm >> View this thread: http://forums.techarena.in/server-scripting/1177796.htm >> >> http://forums.techarena.in >> > > "Richard Mueller [MVP]" <rlmueller-nospam@ameritech.nospam.net> wrote in <snip>message news:eD7evIx0JHA.1432@TK2MSFTNGP02.phx.gbl... > It looks like you ".dll" file is actually a text file . . . Which crystal ball did you use to come to this conclusion? Can I have a loan of it to help me determine what posters mean but never quite get around to spelling out? "Pegasus [MVP]" <n***@microsoft.com> wrote in message I could be wrong, but a true dll wouldn't make much sense. These lines in news:uPg5Akx0JHA.2300@TK2MSFTNGP06.phx.gbl... > > "Richard Mueller [MVP]" <rlmueller-nospam@ameritech.nospam.net> wrote in > message news:eD7evIx0JHA.1432@TK2MSFTNGP02.phx.gbl... >> It looks like you ".dll" file is actually a text file . . . > <snip> > Which crystal ball did you use to come to this conclusion? Can I have a > loan of it to help me determine what posters mean but never quite get > around to spelling out? the posters reply made me decide it was a text file: Eg: .dll file BATCHFILE=D:\ExchangeField_Extraction\ADExch_Exporting_Field.bat RCSVFILE=D:\ExchangeField_Extraction\E2K3AD_field.csv WCSVFILE=D:\ExchangeField_Extraction\E2K3AD_field1.csv I think this an example of the "dll" file. Hi Guys,
Thanks for all the response and suggestion especially Richard Mueller. You understand what i need and finally resolved by your suggestion. Thanks again and this thread is closed. -- LucasYew ------------------------------------------------------------------------ LucasYew's Profile: http://forums.techarena.in/members/76919.htm View this thread: http://forums.techarena.in/server-scripting/1177796.htmhttp://forums.techarena.in
batch file to split multiple text files in half.
Set Local Computer Description Use VBScript to Set Local Computer Description Inventory script question How do implement this wildcard? Logon script help Get computer name as variable to use in vbs script. how do I disjoin a machine to workgroup name anyone know if this is possible? Check if a list of user IDs exist/disabled |
|||||||||||||||||||||||