Askline Question

Started by pman, June 08, 2017, 12:27:33 PM

Previous topic - Next topic

pman

Hi-
A couple of questions-I'm using WBS 2016A.

Is there a way to Assign an askline= to a result=Computernameset( "Asklineinput", 0 )
example.

name=Askline("Computer Name Change","Please Enter New Computer Name.","")
result = ComputerNameSet( "NAME I PUT INTO ASKLINE DIALOGUE",  0 )
Message( "ComputerNameSet", "Set the NetBIOS & Computer name of the local computer.")

Also, could one do the same for a dialogue that writes a txt file


;;;Create a Log File
handle = FileOpen("C:\Sysinfodirectory\%pcname%.txt", "APPEND")
FileWrite(handle, "Install Date: %time1%")
FileWrite(handle, "Technician Name: %techln%,%techfn%")
FileWrite(handle, "Site Location: %techloc%")
FileWrite(handle, "")
Fileclose(handle)

;;;Change Computer Name
result = ComputerNameSet( pcname, 0 )


Thanks from a noob with this soft!


JTaylor

This is one of those questions that make me think I am reading the question wrong but will assume from your final comment that it means exactly what it asks  :)

Sure...the second line would look like:

    result = ComputerNameSet( name,  0 )

The second thing should work as is unless I have just overlooked something but...

It is good to avoid use %substitution%.  There is a place for it and it is WONDERFUL but overuse will come back to bite you.   Assuming 2016A has the ":" concatenator option (Use StrCat() otherwise) the one line might look like:

    FileWrite(handle, "Install Date: ":time1)

I recommend converting all the lines to avoid its use in this case.  One problem is that if the variable doesn't exist then you get no error.  It just substitutes nothing.   So if you mistype a variable name you could easily have blank data for one of your fields and not catch it until you needed the data.

Jim
   

pman

Thanks for the response- yes I am inheriting some of this from prior person, so flailing around somewhat and seeing what works.

In regards to :

name=Askline("Computer Name Change","Please Enter New Computer Name.","")
result = ComputerNameSet( "HOSTNAME I PUT INTO ASKLINE DIALOGUE",  0 )
Message( "ComputerNameSet", "Set the NetBIOS & Computer name of the local computer.")

I get the dialogue, but it doesn't seem to place "HOSTNAME I PUT INTO ASKLINE DIALOGUE" into the ComputerNameSet function (and rename the host ). Is there a call to I'm missing that will insert what I put in the dialogue?

In regards to the second scrap- I will check to see if this version can use the concatenator.   
This script would be the more desirable method to accomplish this task as it has a menu that can be filled by end user-and a record left behind.
My problem is that I'm not sure how to get handle = FileOpen("C:\Sysinfodirectory\%pcname%.txt", "APPEND")
to actually insert just the filename (less the .txt extension)generated from user input  into the result = ComputerNameSet( pcname, 0 )

(it just names the host pcname, lol) I know this is ignorance of the software and have been trying to read into which got me this far at least.
Thanks!








 

JTaylor

Did you change it as I suggested?   "name" is the variable into which the AskLine() value is placed.   Use it without the quotes.

Sounds like you are putting the value in quotes and a making it a literal text value rather than using it as a variable.

If you need to remove the ".txt" from the file name there are numerous ways.   Look a the FileRoot() function for one method.  You could also use ItemRemove().

There is a very good "Intro To Programming Book" on the WinBatch download page that uses WinBatch for its examples.  You would probably benefit greatly working through that book.

Jim