Advertisement

Friday, February 4, 2011

Prevent the programs running from other device other than C:

                 This post is related to the answer of how to prevent the auto run from USB flash drives. Type secpol.msc in the command prompt.
                   You will see the local security windows.Expand the software Restriction Policies. You will see nothing there. Go to Action>All tasks and Select New Software Restriction Policy.You will see the following windows.

          Double Click on the Additional Rules.
                     You will see the two unrestricted file paths.It doesn't say anything about other places like drive D or E. If you don't want to run program from drive D.Right Click on the pane and Choose new path rule. Here you can type the path like D or You can also use the browse button to find a file location that you don't want to run from. One thing you have to remember is Security Level must be disallowed.
                  If you run a program from your drive eg F:\ you will see the following message.

                       But for the portable if can still run from the other devices rather than C:.
I think because the didn't change the registry. Any suggestion.

Sunday, January 30, 2011

Changing date format to "dd-mmm-yyyy" and Making directory in DOS

                       This post describes how to change date from "mm/dd/yyyy" to "dd-mmm-yyyy" and making directory using the converted date. The default date format in the DOS is mm/dd/yyyy eg. for today is 01/30/2011. I want to change this to "dd-mmm-yyyy" format eg. for today is 30-Jan-2011. This format is widely use in Myanmar governmental offices.
                       
Default date in DOS is sun 01/30/2011  for detail go to here http://www.dostips.com/DtTipsStringOperations.php
for /f "tokens=1,2,3,4 delims=/ " %%a in ("%date%") do set wday=%%a&set month=%%b&set day=%%c&set year=%%d
Extract month,day and year form the date string.
Just grab the Month, Day and Year. And then I will change the Month from 01,02 etc.... to Jan,Feb etc....The codes are below
IF %Month% equ 1 Set Month=Jan
IF %Month% equ 2 Set Month=Feb
IF %Month% equ 3 Set Month=Mar
IF %Month% equ 4 Set Month=Apr
IF %Month% equ 5 Set Month=May
IF %Month% equ 6 Set Month=Jun
IF %Month% equ 7 Set Month=Jul
IF %Month% equ 8 Set Month=Aug
IF %Month% equ 9 Set Month=Sep
IF %Month% equ 10 Set Month=Oct
IF %Month% equ 11Set Month=Nov
IF %Month% equ 12 Set Month=Dec
Let try to reassemble.
echo %Day%-%Month%-%Year%
It will appear in screen like 30-Jan-2011
Now Everything is changed to desired format.
 Let finish the date format
Set Date=%Day%-%Month%-%Year%
To make the directory using this customized date format
MD WHATEVER_YOU_WANT_%DATE%_WHATEVER_YOU_WANT
It will appear like
WHATEVER_YOU_WANT_30-Jan-2011_WHATEVER_YOU_WANT

For Newbies
                    Right-Click on the window and choose new text document. Copy the below code and paste into the text file and name it Cdate.bat.
@echo off
::Cdate.bat
for /f "tokens=1,2,3,4 delims=/ " %%a in ("%date%") do set wday=%%a&set month=%%b&set day=%%c&set year=%%d
echo.Weekday: %wday%
echo.Month  : %month%
echo.Day    : %day%
echo.Year   : %year%
IF %Month% equ 1 Set Month=Jan
IF %Month% equ 2 Set Month=Feb
IF %Month% equ 3 Set Month=Mar
IF %Month% equ 4 Set Month=Apr
IF %Month% equ 5 Set Month=May
IF %Month% equ 6 Set Month=Jun
IF %Month% equ 7 Set Month=Jul
IF %Month% equ 8 Set Month=Aug
IF %Month% equ 9 Set Month=Sep
IF %Month% equ 10 Set Month=Oct
IF %Month% equ 11Set Month=Nov
IF %Month% equ 12 Set Month=Dec
echo %Day%-%Month%-%Year%
Set Date=%Day%-%Month%-%Year%::Change the below code to whatever_you_want
MD %1_%Date%_%2
::eg MD Back_%Date%
::MD WHATEVER_YOU_WANT_%DATE%_WHATEVER_YOU_WANT
::Codes are finished here

To use with a variable name
Change the code "MD WHATEVER_YOU_WANT_%DATE%_WHATEVER_YOU_WANT" to
MD %1_%Date%_%2
And Open the command window and Type Cdate.bat Backup Full
Backup is for Variable 1 and Full is for variable 2.
So it will appear like Backup_30-Jan-2011_Full
  Here is the file:Download here After running this batch file you can still use this variable date.