Lisa Johnson
Technical User
Hi
I need two different codes working together
the first one is a VBS script:
Set fso = CreateObject("Scripting.FileSystemObject")
Set file = fso.CreateTextFile("User.bat", False) ' False for ANSI, True for Unicode
Set shell = CreateObject( "WScript.Shell" )
username = shell.ExpandEnvironmentStrings( "%USERNAME%" )
file.WriteLine username
This will get the username and export it to a batch file, or a text file if the extension get changed to .txt
The second code is a batch file used to alter some attributes and permissions
setlocal enableextensions
cd /d "%~dp0"
@echo off
If EXIST "(The user name)" goto UNLOCK
if EXIST "User" goto LOCK
:UNLOCK
echo s| cacls "(The user name)" /G %USERNAME%:F
cls
attrib -H -S -R "(The user name)"
ren "(The user name)" "User"
goto END
:LOCK
ren "User" "(The user name)"
attrib +H +S +R "(The user name)"
echo s| cacls "(The user name)" /D %USERNAME%
goto END
:END
exit
I need that the VBS script executes this Batch file with the “Username” it got in the first place.
This will be part of a security useful application that I'm trying to put together.
All help will be very appreciated.
I need two different codes working together
the first one is a VBS script:
Set fso = CreateObject("Scripting.FileSystemObject")
Set file = fso.CreateTextFile("User.bat", False) ' False for ANSI, True for Unicode
Set shell = CreateObject( "WScript.Shell" )
username = shell.ExpandEnvironmentStrings( "%USERNAME%" )
file.WriteLine username
This will get the username and export it to a batch file, or a text file if the extension get changed to .txt
The second code is a batch file used to alter some attributes and permissions
setlocal enableextensions
cd /d "%~dp0"
@echo off
If EXIST "(The user name)" goto UNLOCK
if EXIST "User" goto LOCK
:UNLOCK
echo s| cacls "(The user name)" /G %USERNAME%:F
cls
attrib -H -S -R "(The user name)"
ren "(The user name)" "User"
goto END
:LOCK
ren "User" "(The user name)"
attrib +H +S +R "(The user name)"
echo s| cacls "(The user name)" /D %USERNAME%
goto END
:END
exit
I need that the VBS script executes this Batch file with the “Username” it got in the first place.
This will be part of a security useful application that I'm trying to put together.
All help will be very appreciated.