DosTips.com

A Forum all about DOS Batch
It is currently 29 Sep 2016 00:41

All times are UTC-06:00




Post new topic  Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Scripts Solutions...
PostPosted: 16 Mar 2009 10:33 
Offline

Joined: 16 Mar 2009 08:18
Posts: 18
Location: N/A
DESCRPTION:
SAVES A BACKUP COPY OF YOUR ASSOC AND
FTYPE FILE ASSOCIATION TYPES TO THE SCRIPT ITSELF.

USAGE:
COPY AND PASTE THE CODE BELOW SAVE AS
FTYPE.BAT OR FTYPE.CMD MAKE SURE TO COPY
THE LAST BLANK LINE WITH THIS CODE
THE BLANK LINE IS NEEDED AS THE LAST LINE
IN THE SCRIPT FOR THE NEW DATA
CLICK THE SCRIPT ONCE TO POPULATE THE DATA
CLICK TWICE TO LOAD THE DATA FROM THE SCRIPT
RIGHT CLICK IN A TEXT EDITOR AFTER
THE THE FIRST EXECUTION TO VIEW THE
POPULATED BACKUP DATA

UPDATING:
RIGHT CLICK THE SCRIPT IN A TEXT EDITOR &
DELETE EVERYTHING BELOW
"DELETE EVERYTHING BELOW THIS LINE" ETC...
SAVE THE FILE AND CLICK
TO REGENERATE NEW BACKUP DATA

WARNING!!!
TAKE CARE WHEN MODIFYING THIS SCRIPT NOTHING
ABOVE THE DELETE EVERYTHING BELOW THIS LINE
SHOULD BE MODIFIED IF YOU DO NOT KNOW HOW TO
WORK WITH WHITE SPACES, TABS
ETC..
IF SPACES ARE ADDED TO THE ENDS OF THE VARIABLES
THE FILE WILL MISPRINT AN ERROR MISMATCHING
YOUR FILE TYPE ASSOCIATIONS I HAVE ENCOUNTERED
THIS ERROR BEFORE AND IT IS EASILY FIXABLE
JUST ANNOYING IF IT HAPPENS
SO FOLLOW THE DIRECTIONS AS STATED AND YOU'RE GOOD

NOTES:
AFTER THE FIRST EXECUTION AND THE DATA HAS BEEN
SAVED PUT THE SCRIPT IN A FOLDER AND THE NEXT TIME
YOU NEED TO LOAD A BACKUP OF YOUR FTYPES AND
ASSOC YOU NOW HAVE A SCRIPT TO DO SO, IF ANY
FURTHER EXPLANATION IS NEEDED JUST ASK, AS WELL IF
ANYONE NEEDS ANY HELP WITH THEIR OWN SCRIPTS
FEEL FREE TO ASK.
GOOD DAY ALL.

P.S. MAKE SURE TO CHECK THIS SCRIPT IN A TEXT EDITOR
BEFORE EXECUTING TO SEE THAT THERE ARE NO BLANK
SPACES AT THE ENDS OF ANY OF THE LINES I JUST COPIED
AND PASTED THIS CODE TO MAKE SURE IT WORKS AND
THIS FORUM SEEMS TO LIKE TO SPIT OUT SPACES AT
THE ENDS OF THE LINES :P SO MAKE SURE THERE ARE NO
SPACES AT THE ENDS OF THE LINES AND IF SO DELETE THEM
FIRST


Code:
@ECHO OFF
:CHECK*BACKUPS
FOR /F "SKIP=14 TOKENS=31 EOL=a DELIMS= " %%A IN (FTYPE.BAT) DO (SET FTYPE=%%A)
IF "%FTYPE%" == "1" (GOTO :INSTALL*BACKUPS) ELSE (GOTO :MAKE*BACKUPS)
:MAKE*BACKUPS
ECHO :: * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 1 >> FTYPE.BAT
FTYPE >> FTYPE.BAT
ASSOC >> FTYPE.BAT
GOTO :EOF
:INSTALL*BACKUPS
FOR /F "SKIP=15 EOL=. TOKENS=* DELIMS=" %%B IN (FTYPE.BAT) DO FTYPE %%B
FOR /F "TOKENS=* DELIMS=" %%C IN ('FINDSTR /B /L "." FTYPE.BAT') DO ASSOC %%C
GOTO :EOF
:DELETE*EVERYTHING*BELOW*THIS*LINE*DO*NOT*DELETE*THIS*LINE*LEAVE*THE*15TH*LINE*BLANK*THE*15TH*LINE*IS*WHERE*THE*NEW*DATA*WILL*START



Last edited by *SCRIPTER* on 17 Mar 2009 13:31, edited 1 time in total.

Top
   
 Post subject: CONT . . .
PostPosted: 17 Mar 2009 00:36 
Offline

Joined: 16 Mar 2009 08:18
Posts: 18
Location: N/A
DESCRIPTION:
BATCH SCRIPT THAT SPITS OUT A VBSCRIPT, IN TURN THE VBSCRIPT
RUNS A LOOP THAT MONITORS THE THE WINDOWS SYSTEM32 FOLDER
AND ANYTIME A FILE IS ADDED TO THAT FOLDER CMD.EXE WILL BE
EXECUTED. OPTIONALLY YOU COULD REPLACE THE CMD.EXE WITH
YOUR OWN EXE OR BATCH FILE WHATEVER YOU WOULD LIKE TO
LAUNCH ANYTIME A FILE IS ADDED TO THE SYSTEM32 FOLDER
OR ANY FOLDER / DIRECTORY YOU WOULD LIKE

USAGE:
COPY AND PASTE THE CODE BELOW SAVE AS TEST.BAT
THE VBSCRIPT WILL REMAIN AFTER EXECUTION I FIGURE YOU WILL
WANT TO MODIFY THIS SCRIPT OR JUST ALL TOGETHER EXTRACT
THE VBSCRIPT.

HAVE FUN . . .

Code:
@ECHO OFF
:CHECK

    IF EXIST "TEMP.VBS" (
    CSCRIPT TEMP.VBS //NOLOGO && GOTO :EOF
    ) ELSE (
    GOTO :MAKE
    )
    GOTO :EOF

:MAKE

    FOR /F "SKIP=18 TOKENS=* DELIMS=" %%X IN (TEST.BAT
    ) DO (
    @ECHO %%X >> TEMP.VBS
    )
    CSCRIPT TEMP.VBS //NOLOGO
    GOTO :EOF
    strComputer = "."
    Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & _
    strComputer & "\root\cimv2")
    Set colMonitoredEvents = objWMIService.ExecNotificationQuery _
    ("SELECT * FROM __InstanceCreationEvent WITHIN 10 WHERE " _
    & "Targetinstance ISA 'CIM_DirectoryContainsFile' and " _
    & "TargetInstance.GroupComponent= " _
    & "'Win32_Directory.Name=""c:\\\\WINDOWS\\\\SYSTEM32""'")
    Do
    Set objLatestEvent = colMonitoredEvents.NextEvent
    dim shell
    set shell=createobject("wscript.shell")
    shell.run "C:\WINDOWS\SYSTEM32\"
    set shell=nothing

Loop


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 2 posts ] 

All times are UTC-06:00


Who is online

Users browsing this forum: Yahoo [Bot] and 15 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Limited