[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

VB script, Create txt file and copy it to network share.

Posted on 2009-04-01
3
Medium Priority
?
700 Views
Last Modified: 2012-05-06
Hello,
I'm looking for a script that will create a txt file of the computer name which ran the script and copy that .txt file up to a network share.

I just need to see when a system has successfully completed a script and copy a txt file with the computer name in the file name to a network share directory. Hopyfully thats pretty straight forware.
0
Comment
Question by:fmcsa001
  • 2
3 Comments
 
LVL 76

Expert Comment

by:David Lee
ID: 24041033
Hi, fmcsa001.

Here's a script for doing this.  Rather than copy the file to the share it just creates it there.  If that won't work, then I can change the script to copy the file.
Dim objFSO, objFile, objShell
Set objFSO = CreateObject("Scripting.FileSystemObject")
'Replace the path and file name on the next line'
Set objFile = objFSO.CreateTextFile("C:\Computer.txt",True)
Set objShell = CreateObject("Wscript.Shell")
objFile.WriteLine objShell.ExpandEnvironmentStrings("%COMPUTERNAME%")
objFile.Close
Set objFile = Nothing
Set objFSO = Nothing
Set objShell = Nothing

Open in new window

0
 

Author Comment

by:fmcsa001
ID: 24041367
This is almost exactly what I need, could you change it so that the file name is the name of the computer instead of computername.txt? (e.g. Frontdesk PC.txt)
0
 
LVL 76

Accepted Solution

by:
David Lee earned 2000 total points
ID: 24044648
Try this.
Dim objFSO, objFile, objShell, strComputerName
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("Wscript.Shell")
strComputerName = objShell.ExpandEnvironmentStrings("%COMPUTERNAME%")
'Replace the path and file name on the next line'
Set objFile = objFSO.CreateTextFile("C:\" & strComputerName,True)
objFile.WriteLine strComputerName
objFile.Close
Set objFile = Nothing
Set objFSO = Nothing
Set objShell = Nothing

Open in new window

0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Welcome, welcome!  If you are new to the series and haven't been following along, please take a brief moment to review the first three installments: Part 1 (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/A_266-VBScri…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question