Jump to content
Seth

Show TXT Contents

Recommended Posts

There is a pretty solid chance I'm posting this in the wrong spot - if this is the case, I apologize.

 

Is there a way to create a custom tab that will display the contents of a specified .txt?

 

I know that in the File Explorer, if you right-click a .txt and select 'View,' a window titled "TexEd" opens with all the contents of the .txt. Does anyone know if there is some way to implement this in a custom tab?

Share this post


Link to post
Share on other sites
There is a pretty solid chance I'm posting this in the wrong spot - if this is the case, I apologize.

 

Is there a way to create a custom tab that will display the contents of a specified .txt?

 

I know that in the File Explorer, if you right-click a .txt and select 'View,' a window titled "TexEd" opens with all the contents of the .txt. Does anyone know if there is some way to implement this in a custom tab?

 

Yes, you can do this. Create your script to create text, upload text, and the copy text file. On your custom tab, change the URL value to read the filename.txt file.

 

Reference the following thread for details: viewtopic.php?f=3&t=323&p=2156&hilit=treesize#p2156

 

I tested and confirmed this to work :)

 

-jeff

Share this post


Link to post
Share on other sites

Awesome. Wasn't sure if just pointing it to the .txt would work, or if it required a .htm/.html file.

 

Ok...now, I just gotta ask - not that I haven't saved myself YEARS of brain-hurt on this site already - is there ANY way to get the .txt to appear as it would in any a .txt viewer? All of the data is being successfully displayed, just without any line-breaks. I assume this is because html requires a to know when to line-break (of which, these text files will have none).

 

For what it's worth:

 

I had originally assumed (possibly incorrectly) that there might be a way to call up the Text Viewer that runs when you select 'View' from within the File Explorer. To test, I viewed the .txt and then checked the listing under 'Commands' from the Computer's Console window. 'Read Text File' is listed as a Command with a parameter value of (simply) the path to the file - which could be adjusted to use %computerid%.txt instead of 304.txt (I'd imagine).

 

BUT...I can't seem to find a way to call that command.

 

Edit I was able to find the command ID for 'Read Text File' (it's 50, for anyone who's interested :P). But I think that just accounts for half of the issue - Displaying it must require some other kind of wizardry. Once I figure out how it displays, the last bit will be to funnel that display into the custom tab somehow. Otherwise, I'd have to somehow find a way to automate the pulling of data out of the .txt file and into LabTech's Extra Data Fields - I'm assuming that would be more work than just hoping for some kind of option that uses "[space]" and "[enter]" as delimiters.

 

Edit x2 - Ok, found that if I save the .txt as a .log file, and change the URL value to the .log file-path then you get a 404 error on the page. BUT, if you reload the page, it will open in a pop-up window. So close....so very close.

Share this post


Link to post
Share on other sites

Explain a little more what you are trying to do I might be able to help. I've done something similar on a tab for BSOD viewer displaying the text file in the correct format. The issue was way more complicated than it had to be in the end.

 

Sent from my LG-D800 using Tapatalk

Share this post


Link to post
Share on other sites

Basically, I'm just trying to get a Malwarebytes log-file (which is .txt by default) to appear in the Custom tab.

 

Here's how the script's setup:

 

IF   Software Installed - %Malwarebytes%
THEN
1 | [yadda-yadda-yadda]
2 | EXECUTE as Admin: "C:\Program Files\Malwarebytes' Anti-Malware\mbam.exe" /logtofile %windir%\LTSvc\MB-Logs\%computerid%.txt and wait until finish, store the result in %executeresult%
3 | [blah-blah-blah]
4 | EXECUTE as Admin: "C:\Program Files\Malwarebytes' Anti-Malware\mbam.exe" /scan -quick -silent -log and wait until finish, store the result in %executeresult%
...(x64  part)...
9 | UPLOAD: %windir%\LTSvc\MB-Logs\%computerid%.txt to LTSHARE\Uploads\, store the result in %uploadedfile%
10| LOG: %uploadedfile%
11| SET: @computerid@ = [LT Server ID]
12| Copy %uploadedfile% to C:\inetpub\wwwroot\LabTech\MB-Logs\%computerid%.txt

 

Though, currently ".txt" has been replaced with ".log" for testing puposes.

Share this post


Link to post
Share on other sites
Basically, I'm just trying to get a Malwarebytes log-file (which is .txt by default) to appear in the Custom tab.

 

Here's how the script's setup:

 

IF   Software Installed - %Malwarebytes%
THEN
1 | [yadda-yadda-yadda]
2 | EXECUTE as Admin: "C:\Program Files\Malwarebytes' Anti-Malware\mbam.exe" /logtofile %windir%\LTSvc\MB-Logs\%computerid%.txt and wait until finish, store the result in %executeresult%
3 | [blah-blah-blah]
4 | EXECUTE as Admin: "C:\Program Files\Malwarebytes' Anti-Malware\mbam.exe" /scan -quick -silent -log and wait until finish, store the result in %executeresult%
...(x64  part)...
9 | UPLOAD: %windir%\LTSvc\MB-Logs\%computerid%.txt to LTSHARE\Uploads\, store the result in %uploadedfile%
10| LOG: %uploadedfile%
11| SET: @computerid@ = [LT Server ID]
12| Copy %uploadedfile% to C:\inetpub\wwwroot\LabTech\MB-Logs\%computerid%.txt

 

Though, currently ".txt" has been replaced with ".log" for testing puposes.

 

 

 

I am guessing this is similar to the issue I was having with the BSOD viewer that the encoding was set to unicode or something and that is why it was coming out wrong.

 

This is the line I used to convert it to ANSI which displayed correctly in a tab.

SHELL: TYPE %windir%\temp\bsod.txt > %windir%\temp\bsod_upload.txt

 

Hope it helps.

Share this post


Link to post
Share on other sites

Seth, Greg is correct. I have tested confirmed this to work. I did this by running function SHELL ENHANCED with command and storing the the results in MyVariable. I then performed function FILE WRITE TEXT with defined path as %windir%\temp\filename.html with Data field as:

 


@MyVariable@

 

Then performed the file upload, etc. TaDa. All formatting retained. :)

 

Hope this helps.

 

-jeff

Share this post


Link to post
Share on other sites
Seth, Greg is correct. I have tested confirmed this to work. I did this by running function SHELL ENHANCED with command and storing the the results in MyVariable. I then performed function FILE WRITE TEXT with defined path as %windir%\temp\filename.html with Data field as:

 


@MyVariable@

 

Then performed the file upload, etc. TaDa. All formatting retained. :)

 

Hope this helps.

 

-jeff

 

 

Awesome.

 

Now, to go full-on retard.

 

Does the following look accurate?

 

---'Shell Enhanced' Step configured as---

Command: "[File Path]\File.txt"
Delimiter: 
Variable: MyVariable

---which would show up in script as---

##| SHELL: "[File Path]\File.txt" and save results to @MyVariable@
##| Write: @MyVariable@ to [File Path]\File.html
##| UPLOAD: [File Path]\File.html to LTSHARE\Upload\, store the result in %uploadedfile%
...

Share this post


Link to post
Share on other sites
Seth,

 

Yes, this looks correct. You are well on your way sir.

 

Good job! :)

 

- jeff

 

Hmm...for whatever reason, this is returning the following:

 

'"C:\Windows\LTSvc\MB-Logs\HELPDESK01-304.txt"' is not recognized as an internal or external command, operable program or batch file.

 

Do I need to adjust it to look like:

 

---'Shell Enhanced' Step configured as---

Command: TYPE "[File Path]\File.txt"
Delimiter:
Variable: MyVariable

---Which would show up in script as---

##| SHELL: TYPE "[File Path]\File.txt" and save results to @MyVariable@

 

Edit: Dagnabbit. TYPE didn't work, either. I don't think. There might be a problem updating the .html file with newer versions. Even after adjusting the script as shown above, the error I'm getting is unchanged. I feel like it should read 'TYPE "C:\Windows\LTSvc\MB-Logs\HELPDESK01-304.html"' is not recognized as an internal or external command, operable program or batch file. if the HTML file was updating.

 

Which is now, I realize, why you went with a temp file location...

Edited by Guest

Share this post


Link to post
Share on other sites

Seth,

 

OK. I think I know what's going on here. If knowledge serves me correctly, MBAM will not execute under the function of SHELL or SHELL AS ADMIN or SHELL ENHANCED as it requires a logged on user console session. This means we must utilize the function CONSOLE EXECUTE. I could be wrong, but don't believe results from a CONSOLE SHELL can be stored in a variable and passed to write to file. I'm performing some testing on this now.

 

If you want, export your script and upload. I'll test and tweak on this end and re-up when completed. Thanks. :)

 

-jeff

Share this post


Link to post
Share on other sites

Sure thing.

 

And I was considering that MBAM restriction, as well - I just wasn't sure if it would still be applicable to the txt log, after it's been generated and saved.

 

We're working with a PRO Version (testing on my workstation), in which we have an install script (which will default install a 'free' version) and a script for Quick Scan, Quick Scan and Clean, Full Scan, and Full Scan and Clean (all set to register, configure default save location for log file, update, and run specific scan, based on CMD parameters in MBAM help file).

 

I tried to upload the Quick Scan script (as that is serving to be the basis for the others, short scan-time w/no threat of accidental file-deletion), but got an error due to it being an XML file. Is there a way around this? (Will check Forum FAQ's right after submitting this reply, as well).

 

As a side-note...I deleted the .html file from LTServer\C$\inetpub\wwwroot\LabTech\MB-Logs\ (where the Custom Tab is set to look), and refreshed LabTech...but am not getting a 404 error when viewing the tab. In fact, still getting the intial error response. There might be more going on than meets the eye, here.

Share this post


Link to post
Share on other sites

Seth,

 

I have confirmed that funtion CONSOLE EXECUTE cannot pass the stored results. If MBAM can run under SHELL ENHANCED via CL, with specified log file output, then the logfile output can be stored to defined variable and written to file.

 

Here is a simple example of a script to do that using CL for IPCONFIG /ALL:

 

 

 

If we can do the same concept with MBAM, then we can accomplish your goal.

 

-jeff

Capture.JPG.f1f6780c16c6c4ee5ce166884dda25b5.JPG

Share this post


Link to post
Share on other sites
Sure thing.

 

And I was considering that MBAM restriction, as well - I just wasn't sure if it would still be applicable to the txt log, after it's been generated and saved.

 

We're working with a PRO Version (testing on my workstation), in which we have an install script (which will default install a 'free' version) and a script for Quick Scan, Quick Scan and Clean, Full Scan, and Full Scan and Clean (all set to register, configure default save location for log file, update, and run specific scan, based on CMD parameters in MBAM help file).

 

I tried to upload the Quick Scan script (as that is serving to be the basis for the others, short scan-time w/no threat of accidental file-deletion), but got an error due to it being an XML file. Is there a way around this? (Will check Forum FAQ's right after submitting this reply, as well).

 

As a side-note...I deleted the .html file from LTServer\C$\inetpub\wwwroot\LabTech\MB-Logs\ (where the Custom Tab is set to look), and refreshed LabTech...but am not getting a 404 error when viewing the tab. In fact, still getting the intial error response. There might be more going on than meets the eye, here.

 

 

Seth,

 

You will need to zip the xml script before you post to forum.

 

-jeff

Share this post


Link to post
Share on other sites

Seth,

 

I have downloaded your script and tested. I had 100% success with your scripts and after careful review, I'm not seeing any issues. A couple of things to verify though.

 

Line 13 of your QuickScan script..ensure ID matches your LT server

Be sure to perform IIS reset after you create the MB-Logs folder under c:\inetpub\wwwroot\labtech

Check the configuration of your custom tab: (focus on the URL)

 

 

 

If you get the custom tab configured correctly, I think you got this. :)

 

-jeff

Capture.JPG.9015f93cf2966bd87871f5715a88e2d6.JPG

Share this post


Link to post
Share on other sites

I know this is an old Thread, however has anyone made this or something similar work with IIS logs. I'm struggling with how to get IIS logs into Labtech. I guess one of the main issues is the changing file names each day.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...