Batch Ex Amp Let
Batch Ex Amp Let
Batch Ex Amp Let
Password Example
The following batch file can be used to establish a password for running a program. The batch file is
named START.BAT and calls the program named CALC.EXE.
@ECHO OFF
IF %1==ExeScript GOTO OK
ECHO WRONG PASSWORD
GOTO END
:OK
ECHO PASSWORD IS ACCEPTED...STARTING
CALC.EXE
:END
Now use the correct password. Type the correct command at the prompt.
C:/>
C:/>START ExeScript
C:/>PASSWORD IS ACCEPTED...STARTING
@echo off
if not "%1"=="" goto argsok
echo usage: %0 backupdir
echo where: backupdir is the directory to copy your .doc files
goto end
:argsok
setlocal
set backupdir=%1
if not exist %backupdir% goto notfile
echo %backupdir% is a file
goto end
:notfile
rem If the directory does not exist, create it.
if exist %backupdir%\nul goto skipdir
md %backupdir%
if "%errorlevel%"=="0" goto skipdir
echo Error creating backup directory
goto end
:skipdir
rem Copy each .doc file one at a time.
rem Note: the for loop variable (%%b) must be contain only one letter.
for %%b in ( *.doc ) do copy %%b %backupdir% > nul
rem Use the for loop again to check if each file was copied (since it is
rem difficult to run multiple commands in a for loop).
for %%b in ( *.doc ) do if not exist %backupdir%\%%b echo %%b was not copied
:end
rem Clean up
endlocal
An alternate slightly more complicated method that, to our knowledge, cannot be used in Windows NT,
Windows 2000 or Windows ME would be the following:
For the above batch file to work properly, you must create a file called log by typing "edit log" (without
the quotes) and then save and exit the file which will create the file at 0 bytes. If this file is not created
or not created properly, you will receive the error message, "Content of destination lost before copy".
Here are some Useful command line batch
files we have written to help us out.
The command prompt is alive and well in Citrix Winframe and Metaframe, it is often faster and
more efficient to do things from it than from winstation administration. Below are some great
helps to make it even more efficient for you.
===========================================================================
Killall.bat
The text between the double lines is what you type at the command prompt to create the files.
Here is the most useful one we have it is called Killall.bat all you need to do is type killall
followed by the workstation id numbers you want to reset ex: killall 21 22 23 24. This
works great if you need to log multiple users off to fix a problem.
===================
================
We created these two batch files to quickly disable and reenable logons. We created an Icon
from the batch files. and added it to our admin group. You can omit the Rem lines.
===================
==================
S.bat
S.bat was created to get a status of another server from any of our servers. Our servers are
named Citrix1 - Citrix5 You will need to substitute your server names for the word Citrix. You
would type s and then the server number ex. s 1. Hopefully your server names are sequentially
numbered or this wont work.
=========================
=========================================================
Deltree.bat
Deltree.bat is a batch file I found on the web to solve a major problem with NT. We needed a
way to delete all files within a subdirectory without deleting the directory itself, and also avoid
having to answer y a million times. The deltree command is gone in NT so this is the way around
it. We use this to clear our Temp Directory as well as delete and recopy program subdirectorys
when files get corrupted. The command is such you would type deltree then the drive and
directory you want to delete for example deltree c:/temp
==================================================
Another simpler way to delete all files from a subdirectory but it takes up two lines in your batch
file is to use the below two lines:
The first line clears out the files in the root and all subdirectories(/s)without prompting, the
second line deletes the subdirectory folders. Make sure you have the \ at the end of the directory
name on the second line or it will delete the directory also. Sometimes this command deletes the
temp directory. Thus the md statement to recreate it. It is ignored if the directory exists. The
cacls command gives everyone full permission to write to the temp directory in case someone
accidently took permission of it.
Pro.bat
Pro.bat was written to view the running processes on the system you are on. We have found that
a process stuck in the run state for a long period of time is usually a runaway and killing that
process will bring a server back to life.
============================
P.bat
P.bat took pro.bat one step further it gave us the ability to look at processes on our other servers.
Just by typing in P and the number of the server. Ex. P 1. Note like s.bat that you have to
substitute the word Citrix with the name/number of your server and hopefully they are
sequentially numbered.
==============================
@echo off
cls
qprocess * /server:CITRIX%1
if CITRIX(%1).==CITRIX(). goto end
:end