Hello everybody,
I'm trying to convert a BAT script to VBS, i'm also new in the VBS world.
I've already tried some scripts frome google.
This is the BAT script:
This is the VBS script which i found on google.com, the VBS script doesn't work.
The VBS script must read the .txt file and if the name in the .txt file contains the same name as the computer himself, the script must remove the .txt file.
Thanks, Rowan
I'm trying to convert a BAT script to VBS, i'm also new in the VBS world.
I've already tried some scripts frome google.
This is the BAT script:
Code:
@echo off
pushd %LOGONSERVER%\netlogon\LimitLogin\
For /F "Tokens=1" %%I in ('TYPE Z:\LimitLogin\logs\%USERNAME%.txt') Do Set COMPNAME=%%I
IF "%COMPNAME%" EQU "%COMPUTERNAME%" DEL "Z:\LimitLogin\logs\%USERNAME%.txt"
:END
popd
This is the VBS script which i found on google.com, the VBS script doesn't work.
Code:
Set oFSO = CreateObject("Scripting.FileSystemObject")
set WSHShell = wscript.createObject("wscript.shell")
set objNetwork = WScript.CreateObject("WScript.Network")
Set fso = CreateObject("Scripting.FileSystemObject")
strComputerName = wshShell.ExpandEnvironmentStrings( "%COMPUTERNAME%" )
CompName = WshShell.ExpandEnvironmentStrings("%COMPUTERNAME%")
UserName = WshShell.ExpandEnvironmentStrings("%USERNAME%")
LogServer = WshShell.ExpandEnvironmentStrings("%LOGONSERVER%")
Dim fso, myFolderName, objFolder, myFileName, objFile, myFQFilename, objTextStream, fileContents
Set fso = CreateObject("Scripting.FileSystemObject")
Dim forReading, forWriting, forAppending
forReading = 1
forWriting = 2
forAppending = 8
myFileName = (""& LogServer &"\NETLOGON\LimitLogin\Logs\"& UserName &".txt")
Set objTextStream = fso.OpenTextFile(myFileName, forReading)
fileContents = objTextStream.ReadAll
If objTextStream.ReadAll ("strComputerName") then
fso.DeleteFile (""& LogServer &"\NETLOGON\LimitLogin\Logs\"& UserName &".txt"), True
Else
WScript.quit
END
The VBS script must read the .txt file and if the name in the .txt file contains the same name as the computer himself, the script must remove the .txt file.
Thanks, Rowan