Search This Blog

Showing posts with label batch-script. Show all posts
Showing posts with label batch-script. Show all posts

Batch Script for Creating An User and Adding to Member of Local Administrators Group

I built a batch script to create a local user and add it to the local administrators group. The script requires two arguments – one is the user’s login name, another is the user’s full name. The user’s password is hard-coded, but it can be changed to an argument with a small modification.

@echo off
set PASSWORD=XXXXXXXXX

REM add a local user with password
net user %1 %PASSWORD% /add /fullname:%2

REM add a local user to the administrators group
net localgroup administrators %1 /add

One thing I learned is that not all options (e.g. /fullname) are showed when typing “net user /?”. For more other options, see this Technet document.

Launch VBScript in a Logon Batch Script

An example of a batch file Logon script that launches a VBScript program is as follows:

@echo off
wscript %0\..\NetLogon.vbs

The "%0" in the batch file is interpreted by the command processor to be the name and path of the current file, which is the batch file itself. The string "%0\..\" then becomes the folder where the batch file is stored. The batch file above will launch the VBScript program NetLogon.vbs as long as it is saved in the NetLogon share with the batch file. This syntax is preferable to a UNC path, because it does not hard code the name of a Domain Controller. The syntax will work no matter which Domain Controller authenticates the user. The logon script will work no matter which Domain Controllers are available or where in the network the user logs on.

Reference: http://www.rlmueller.net/index.html

Batch File for Checking OS Architecture Type

@echo off
echo Detecting OS processor type

if "%PROCESSOR_ARCHITECTURE%"=="AMD64" goto 64BIT
echo 32-bit OS
REM Run 32-bit executable
goto END

:64BIT
echo 64-bit OS
REM Run 62-bit executable

:END

Batch File for Checking OS Architecture Type

@echo off
echo Detecting OS processor type

if "%PROCESSOR_ARCHITECTURE%"=="AMD64" goto 64BIT
echo 32-bit OS
REM Run 32-bit executable
goto END
:64BIT
echo 64-bit OS
REM Run 62-bit executable
:END

Use WinSCP to Transfer Files in vCSA 6.7

This is a quick update on my previous post “ Use WinSCP to Transfer Files in vCSA 6.5 ”. When I try the same SFTP server setting in vCSA 6.7...