Insert tabs and text into a text file
Hi all,
As you can tell by my name, I am completely new at this. My coworker and I are creating a small package that grabs the current IP of the PC in question, then puts it into a host file. We've gotten as far as putting the IP in the host file, however, we would like to have it say "Landesk" then a tab, then the IP. We are stumped as to how to insert a tab between landesk and the IP, and for the matter, we're stumped as to how to get landesk before the IP, as it seems to put it at the top of the text file, regardless of whether there's already text there or not. So, to sum it up, we need the file to say "Landesk <tab> <IP address>".
I've done a search here on the forum and haven't found anything as of yet, so any help would be much appreciated.
Thanks.
As you can tell by my name, I am completely new at this. My coworker and I are creating a small package that grabs the current IP of the PC in question, then puts it into a host file. We've gotten as far as putting the IP in the host file, however, we would like to have it say "Landesk" then a tab, then the IP. We are stumped as to how to insert a tab between landesk and the IP, and for the matter, we're stumped as to how to get landesk before the IP, as it seems to put it at the top of the text file, regardless of whether there's already text there or not. So, to sum it up, we need the file to say "Landesk <tab> <IP address>".
I've done a search here on the forum and haven't found anything as of yet, so any help would be much appreciated.
Thanks.
0 Comments
[ + ] Show comments
Answers (3)
Please log in to answer
Posted by:
plangton
20 years ago
Hi Wisen00b,
Personally, I would do a custom action as a vbs file. To do what you want the vbscript could look like this (note that I'm no scripting guru so someone else might have a better way...):
hostfile = "C:\WINDOWS\system32\drivers\etc\hosts"
Set fso = CreateObject("Scripting.FileSystemObject")
set txtStream = fso.OpenTextFile(hostfile, 8, True)
txtStream.WriteLine "192.0.0.1" & vbtab & "Landesk"
Set txtStream = Nothing
Run this as a custom action and it should be fine. Note you'll want to change the IP address (obviously).
Hope that helps
Paul
Personally, I would do a custom action as a vbs file. To do what you want the vbscript could look like this (note that I'm no scripting guru so someone else might have a better way...):
hostfile = "C:\WINDOWS\system32\drivers\etc\hosts"
Set fso = CreateObject("Scripting.FileSystemObject")
set txtStream = fso.OpenTextFile(hostfile, 8, True)
txtStream.WriteLine "192.0.0.1" & vbtab & "Landesk"
Set txtStream = Nothing
Run this as a custom action and it should be fine. Note you'll want to change the IP address (obviously).
Hope that helps
Paul
Posted by:
Danno
19 years ago
The quick way to complete this task is to use the script editor and simply use the action "Insert line into text file". Get the IP into a variable like %IP%. Your insert line should look like "LANDESK %IP%". You can use notepad to create the text line to insert, then just cut and paste it into the action.
Posted by:
Wisenoob
19 years ago
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
so that the conversation will remain readable.