Search This Blog

Showing posts with label DOS. Show all posts
Showing posts with label DOS. Show all posts

Sunday, December 25, 2011

Using Batch Files to Automate Networking Tasks - PART3


How to Restart Services On All Domain Controllers Within a Domain

To restart service on all domain controllers within a domain, perform the following steps: 

  1. Create the Restart.bat and Restart2.bat files listed below.
  2. Run the Restart.bat Service Name from a computer running Windows NT using administrator privileges. The Restart.bat file issues the Windows NT Resource Kit utility NETDOM to create a file called Netdom.txt. The Netdom.txt file gets parsed using the FOR command (part of Windows NT command extensions). Each \\DomainControllerName gets passed to the Restart2.bat file where the Windows NT Resource Kit utility NETSVC command gets issued to stop and start the Service Name entered at the command prompt.
Filename: RESTART.BAT 

echo off
cls
if (%1)==() goto NoParams
netdom bdc > netdom.txt
for /F "skip=6 tokens=4" %%a in (netdom.txt) do call restart2.bat
%%a %1
echo ---------
echo - Done! -
echo ---------
goto bottom
:NoParams
echo usage: RESTART "Service Name"
echo.
echo. i.e.- RESTART "License Logging Service"
echo.
:bottom
    

Filename: RESTART2.BAT 

echo Restarting %2 on %1
netsvc %2 %1 /stop
netsvc %2 %1 /start
echo.
  

Using Batch Files to Automate Networking Tasks - PART2


How to Add Files to Many Users' Home Directories

To add files to many users' home directories, perform the following steps: 

  1. Create the Addfile.bat and Addfile2.bat files listed below.
  2. Run Addfile.bat <Parent Directory> <File to Add> with administrative privileges from a computer running Windows NT. The Addfile.bat file simply issues a DIR command and redirects the output to a file, which in turn gets parsed using the FOR command (part of Windows NT command extensions). The Addfile2.bat file gets called once for each directory name listed in the Dir.txt file. The Addfile2.bat file issues a copy command to copy the file to each user directories.
Filename: ADDFILE.BAT
v
echo off
cls
IF (%1)==() GOTO NoParams
IF (%2)==() GOTO NoParams
Echo Creating directory listing...
dir %1 > dir.txt
for /F "skip=7 tokens=4" %%a in (dir.txt) do call addfile2.bat %%a
%1 %2
echo ---------
echo - Done! -
echo ---------
GOTO Bottom
:NoParams
ECHO usage: ADDFILE [Parent Directory] [File to Add]
ECHO.
ECHO  i.e.- ADDFILE C:\PROFILES MyFile.lnk
ECHO.
:Bottom
    

Filename: ADDFILE2.BAT 
if (%1)==() goto bottom
if (%1)==(bytes) goto bottom
copy %3 %2\%1
:bottom
    

Using Batch Files to Automate Networking Tasks - PART1

This article demonstrates a few ways to use Windows NT command extensions in conjunction with Windows NT Resource Kit utilities within batch files to automate common networking tasks. 

The following tasks will be illustrated: 

  • How to automate the addition of Domain\Domain Users global group to each of the member servers Change the system time user right.
  • How to add files to many users' home directories.
  • How to restart services on all domain controllers within a domain.

How to Automate the Addition of Domain\Domain Users

How to automate the addition of "Domain\Domain Users" global group to each of the member servers "Change the system time" user right. 

  1. Create the Addtime.bat and Addtime2.BAT files listed below.
  2. Run Addtime.bat with administrator privileges from a computer running Windows NT. This batch file creates a list of member servers using the Windows NT Resource Kit utility Netdom.exe. The output of NETDOM gets redirected to a file, which in turn, gets parsed using the FOR command (part of Windows NT command extensions). The Addtime2.bat file gets called for each instance of \\ServerName within the Netdom.txt file. The Addtime2.bat file then issues the Windows NT Resource Kit utility Ntrights.exe to add Domain\Domain Users global group to each of the member servers Change the system time user right. The output of NTRIGHTS gets written to a file called Log.txt.
Filename: Addtime.bat 

echo off
cls
echo Creating a list of member servers.
echo.
netdom member > netdom.txt
echo Adding "Change System Time" right to Member Servers...
echo.
if exist log.txt del log.txt
for /F "skip=6 tokens=4" %%a in (netdom.txt) do 
   call ADDTIME2.bat %%a
echo.
echo ----------------------------------------------
echo - Done! Check LOG.TXT for status information.-
echo ----------------------------------------------
    


Filename: ADDTIME2.BAT 

echo Adding right to %1...
ntrights -u "domain users" -m %1 +r SeSystemTimePrivilege >> log.txt
    

Friday, December 2, 2011

Run DOS programs in Windows 7

Here's the general rule: If the DOS program ran in XP, it will probably run in a 32-bit version of Windows 7. But no DOS program can ever run in a 64-bit version of Windows 7.
Except that there's a workaround. I'll explain it in a minute.
If you're not sure whether your Windows is 32- or 64-bit, click the Start orb, right-click Computer, and select Properties. Look for the System type.
You can launch most DOS apps in a 32-bit version of Windows 7 simply by double-clicking the DOS program's .exe or .com file. If it doesn't work, or if there are problems, right-click the file and selectProperties. Click the Compatibility tab. Check the "Run this program in compatibility mode for" option and select an older version of Windows. You may have to do some experimenting to find the right one.
And if none of those work, try the 64-bit solution below.
Actually, there are several solutions, all of which involve using software to create a virtual machine (VM) inside Windows. If you want to run a lot of different operating systems inside Windows, VMware Player is probably your best bet.
But if all you're only looking for is a way to run DOS programs, try DOSBox, a free program that launches a DOS VM. I can't promise it will work with every program you throw at it, but it worked for every one I tried.
Once you download and install DOSBox, here's how to set it up so that it can find and work with your DOS programs and files:
  1. Create a folder (just as an example, let's call it C:\DOSFiles) and place in it every program and file you want DOSBox to access. You can use subfolders within that folder.
  2. Click Start, type notepad and press ENTER to bring up Notepad.
  3. Click Start, and select All Programs, DOSBox-0.74 (the version number may change), Extras, Screenshots & Recordings.
  4. This will open Windows Explorer to a probably empty folder inside the DOSBox configuration folder. In the path bar at the top of the window, click DOSBox to go to that folder.
  5. Drag the file dosbox-0.74.conf into Notepad. (The .conf part will probably not be visible.)
  6. In Notepad, go to the bottom of the file, where you'll find the [autoexec] section.
  7. On a blank line at the end of the file, type mount driveletter path, where driveletter is the drive letter you wish to assign the folder to, and path is the path to that folder. For instance, mount a c:\dosfileswil make the C:\DOSFiles folder appear as DOSBox's drive A:.
  8. Save the file and launch DOSBox.