Jump to content

Batch Files and Command Prompts


AwfulArchdemon

Recommended Posts

Posted

Since the Lab doesn't get very deep into technical things, like how to use your comp's most basic commands, and how to make a basic start-up program (you can make anything start when your comp turns on) happen upon initial log-on, I decided to cover this most interesting topic.

 

I love this place, so I'll try to be as helpful as I possibly can for all of you, but I expect the pros to offer awesome feedback, and inform us of fundamental and ingenious codes you have made helpful use of through the years. Windows 7 is a wonderful OS, so this should mean no extra work for it's users. Just read, and do as I instruct.

 

FIRST: Press the Widows button on your computer's keyboard, or click the Windows icon on the bottom left of your desktop.

 

You will see your computer's default Windows menu. There will be a search bar in the field on the bottom of this menu. Type into that field.

 

If you are doing something important, that involves using your cmd (command prompt) exclusively (like installing/running SDelete), then you will want to run the cmd 'as administrator', which can be done by right-clicking the cmd when it shows, and clicking 'run as administrator'.

 

If you are wondering what SDelete is, I will SO tell you. It is how to truly erase files from your computer, instead of the fake way that Recycle Bin provides. Visit http://www.sysinternals.com/ to find out more on how to do amazing things to your computer.

 

Here is SDelete.

 

Batch files:

 

Here are some basic batch file recipes for you to screw around with. They will be explained as I go.

 

Open notepad, and type this:

@echo off

start shutdown -r -t 10 -c "Fuck You Buddy!"

 

When you close the file, you'll be prompted to save. Do so. Name it FuckYouBuddy. This means you now have a text file made, named
FuckYouBuddy.txt. Rename it to say FuckYouBuddy.bat.

 

More specifically:

FuckYouBuddy.bat will now perform the following function:

start shutdown -r...

-r is the restart command

-t is the timer, and in this case, it's set to 10 seconds

-c is the "comment". Fuck you, buddy...

 

When you run this batch file, it will restart your computer. It will take 10 seconds for the restart to begin. It will be quite rude to you as well, as it is without manners.

 

Easy site access:
@echo off

start http://www.loverslab.com/

start http://www.nexusmods.com/

 

This is an incredibly simple command, that just opens LL and Nexus on your comp. 
For those of you who visit both sites regularly, this can be very handy to have right on your desktop. I use a batch file to visit both sites, but mine are individual sites, like Duck.bat, for example. It opens DuckDuckGo.com, so I can browse around with out the world reading every keystroke, and selling my info and shit. DirectLabLink.bat is how I get here every day.

 

@echo off

cd C:\Program Files (x86)

start sdelete -z

 

This could be a handy batch if you planned on using SDelete to zero your free space (and ONLY if that's what you're doing). You would of course have to have SDelete properly installed to achieve this through the use 'command prompt'. This absolutely requires you to learn command prompts.

 

 

 

 

 

Command Prompts:

 

You can tell your computer to do anything, if you know how to communicate with your computer. You can open the cmd, and type 'help'. This will open a large menu of commands that your computer recognizes. If you type in a URL, and for some reason you need to know how many digits are in it, you can type it into cmd; IE. Your comp will answer your questions. It even tells you the date and time, if you know how to ask it.

 

 

Open cmd. Type start http://www.loverslab.com/. You'll end up on LL.

 

Command prompt is as powerful as it gets when running your computer. This page can teach you anything you want to know about cmd. It is literally school for coding. A useful video for using the command prompt can be found on YouTube (of couse), and that vid can be also be found right......here, so there's no need to go clicking on stuff on Scroogle.

 

You can do something as simple as this: direct_LabLink.rar Unzip, and run. This is my introduction to batch files.

 

Open your Windows menu, and type in "notepad", if it isn't already an option. Press 'enter'.

 

Type this:

@start http://www,loverslab.com/

Click the 'X' at the top right, as if you were abandoning the .txt file. It will ask if you want to save. 
The correct answer is YES.

Choose to 'save', and you'll get to name your file right away. Name it whatever you want, but remember to change the name of your file from .txt to .bat.

Repeat;

.txt>.bat

Once you have renamed the last 4 digits, you will be warned that changing the file name may cause the file to be rendered unusable. Kick that warning right in the balls, and move on with your save. Save it to your desktop, which should be it's default location.

 

A text file is a batch file waiting to happen, if it's filled with the correct codes.

 

Here's a good example:

 

Here: Matrix_Sound.rar Unzip this, and run it. You'll hear a cool matrix sound play.

 

This will create the 'mood' for this little demonstration.

 

Here: AwfulArchdemon_Matrix.rar Run this next. You'll see a column of random digits. Drag the bottom/top of the column to fill one third of your desktop screen, and position on the left. Run it again, and position the new column to fill the right third of your screen, top to bottom. Run a third, and final time, and position to fill the center. Arrange them so they look just right, and you now have a full blown matrix kicking on your desktop.

 

This is just for fun, but there are many things you can do with a command prompt.

 

For example:

I'll bet you thought files were not actually deleted when you deleted them. You were right. Running your cmd is the equivalent of typing paths into Windows 'search'. You can't erase files that were deleted, unless you use command prompt to SDelete it. The same concept holds true with cookies, and more importantly, viruses. For example:

I'll bet you can't (double) click on C:\Users\Owner\AppData\Local

You'll have to type that in, and that sucks ass, because that's a path that cookies take. Viruses too. Viruses take paths you may not be able to find by double-clicking your files.

 

 

 

I will give a much more detailed explanation soon, but for now, I'm inviting more skilled coders to lend their knowledge to the cause. These members deserve an explanation of the unknown 'command prompt', and it's functions. No more seeing the little black screen and thinking it's a bad thing, or a maze, that can't be navigated, without a college education.

 

This is your guide. Use it well. I'll field all questions to the best of my ability, and I expect all knowledgeable members to do the same, as usual.  ;)

 

 

 

AwfulArchdemon

AwfulArchdemon_Matrix.rar

Posted

Abort.rar

Know what that is? Unzip, run, and nothing will happen. Nothing.

 

Would you like to know why in the world that's a good thing? All you have to do......is stay tuned...to Batch Files and Command Prompts!

 

 

So, you've learned a bit about command prompts, and you know what words your computer will recognize. Can you disinfect a virus without an anti-virus like Webroot or Kaspersky? Can you even use SDelete properly yet? Have you asked your computer how many digits are in the URL http://www.loverslab.com/ yet? NO!? Here is a link and a video that will teach you how to do the really basic things with your command prompt:

 

Link: http://www.wikihow.com/Use-the-Command-Prompt-and-Write-in-Batch-Language

Video: http://www.youtube.com/watch?v=2Ey6VN7nqkA

 

The video is very helpful. He tends to talk too much though...

 

Anyway, I'll answer any questions and keep updating the thread as I learn  :P, so if you have any really good advice, or a question, please feel free to post it.

 

My support team (me) is always available (eventually)!

Posted

Okay. Now, I'll tell you why that file is a good thing. Download and run this virusAwfulArchdemon_virus.rar

 

You now have a decision to make. After you run it, you'll be told what to do. Spoiler, kinda, is you should run Abort immediately (or at least shortly after). You have 20 seconds to decide.

 

 

Should you do nothing, your computer will restart.

 

 

That's about it. Not very impressive, I know. 
The impressive part is when the Abort program prevents it.

 

 

Abort should be kept at the bottom right side of your comp at all times.

 

 

Abort can and will prevent any shutdown or restart commands given to your comp. It's the exact solution to the 'problem' I've purposely given you.

 

Should you choose to ignore the warning:

It's not much of a warning, because it's not much of a problem. It will restart your comp once, and then sit there, doing nothing.

 

Worst case scenario:

You should exit any programs, and save any progress you don't want to lose, because a restart is...a restart. You'll lose unsaved stuff, obviously, so save everything you're doing 1st, IF you plan on testing me to see if my "virus" actually does what I say it will do. It will.

 

Go ahead, run your antivirus programs and SuperAntiSpyware, and MalWareBytes, and yada yada yada...it's one weak-ass virus. Your antivirus will laugh at it, and let it pass.

 

Any technical questions, do not hesitate to ask. I have a full team of person waiting to answer your questions, working 'round' the clock, so "we" will respond at once, for that is how LL rolls.  B)

 

 

 

 

Be safe.

Posted

So I'm willing to bet you all think I'm crazy for literally telling you to dl and run my "virus". If it weren't made by me, I'd never suggest it. If you're curious as to what it is and does, look at my post under Batch Files. It's almost the same exact formula. I'm a big fan of not being arrested, and I like it here on LL, so rest assured it's 100% safe to run. No surprises.

 

Don't believe me? Remember, you can always right-click any batch file, and scroll down to edit, to read what's in it, without it actually running.

 

  • CMDCommand_prompt_icon_%28windows%29.png

 

 

CMD and batch files are best friends. I know I went into some more details about batch files under the Command Prompt header, but that's just because you'll see your cmd run when you use a .bat file. It's the equivalent of typing into the command prompt directly, really fast.

 

A command can be horribly dangerous, so I don't recommend "trying stuff out, just to see what it does". Learn the safe way. When I say horribly dangerous, I mean, if I typed the right batch file, and said run this to someone, it would erase their computer 100%. I don't mean a drive wipe, I mean the comp would be finished. Nothing left. Therefore, experimenting with batch files is not recommended, until you gain a decent understanding of their capabilities, and by "their capabilities", I mean cmd commands.

 

Command prompts are used when a .bat is ran. Certain .bat files are written to access information when playing a game. In Skyrim (for example), you can type something like "bat resetumbrella" into the console. We'll say for example that this would reset the "deploy umbrella" animations, and delete any umbrellas being used in-game at the time. If the mod was activated, but nothing appears to have happened, it may very well be that the mod is made to need the bat file to be ran before the files are referenced, meaning nothing will be active yet, even if the mod was activated in MO (or whatever you use as a manager).

 

Batch files are used a lot in games, so learning those will be wise if you plan on modding.

 

Every time I want to go to LL or Nexus, I use a batch file to get there. If there's a site url I want to revisit, I just copy/paste the address into a text file, save, and type "@start " right before the url, and rename the .txt to .bat.

 

When I run it, it takes me to the page using cmd. Very handy for people who need to go to various sites a lot.

 

Saves having to relocate it, or typing in the url. Some url's are just too long to have to keep typing, and copying to a text file, and going to that text every time you want to go there, and copy/pasting the address from the text file to the url bar at the top of your IE (or whatever you use to browse). It can be nice, but making a batch is much quicker. Great for lazy people.

 

I recommend making a list of frequently visited site url's in a text file, so you always have them printed somewhere, just in case you lose a batch file somehow. I place my lists in my Libraries\Pictures directory. Afterall, I don't want a lot of bats flying around on my desktop, but you could always make a folder called "bats" on your desktop, and keep regularly used batch files in there. Just some suggestions to make life easier.

 

Any questions, just ask. As usual, all pros are welcome (and invited) to add technical input to this thread. There's a lot of information to learn about batch files, and I don't know it all. I may even ask a question or 2 myself here. :blush:

Posted

Seems like a pretty desperate measure to get rid of "deleted" files, unless you plan on doing that anyway.

 

You'll have nothing left behind, including "hidden files" IF you delete the partition first. Reformatting should be a last resort. Be damned sure to back up files you want to keep before doing this. If you just want to erase files, SDelete is the way to go. You don't have to send files to the Recycle Bin, empty it and clear free space (-Z) to SDelete files. You can just direct SDelete to the file's path to do it quickly. Zeroing free space is still a good idea though.

Posted

In this area i know what im doing i always make sure ive copys of files i realy need. And these days its not that hard to format reasonble fast, early days took me hours sometimes even days now its finished within hour only windows updates take bit longer most of my files ive already on standby.

 

Im just not font of thirdparty programs doing it for me i always do it manually myself.

 

Ive almost never any problems with my pc i also never have virus or other vicious programs still i don't use any protection program besides the one from MS. I know how to behave on the internet but have little knowledge of what your showing here hehe

 

I know some cmd promt commands but thats very limited the basics.

 

Ive study extensively chess for many years thats enough study for me i can't take any study anymore or im going crazy:P

 

I don't touch your skills you showed here but its very nice learn here on forum by reading about it, more knowledge can't hurt eather:)

  • 2 weeks later...
Posted

Thanks, but my skills are soft, compared to the pros. I've gotten a great offer, to post a couple of truly well made, and complicated-as-hell batch files, but it appears I need to do some homework 1st, and add missing info to it, to be allowed to post it.  :D Interesting concept. lol I have to make this happen, so I'll be learning coding, it seems. I need to.

 

So, I will be updating this thread soon. As I learn, so too will I post. By the time I'm done, this thread should count as a class. I'll return here when I make something impressive. I'll also teach some other things, like how to make programs run when you start your computer, and how to create a .exe. Things like making a .exe are already on your comp, waiting to be used. There are many, many things on your comp that you don't know about. I'll bet you've never seen this path: C:\Windows\System32\Drivers\etc\hosts It serves a purpose, and I'll even get into that, when I return.

  • 2 weeks later...
Posted

I know I promised a lot......so here's a lot!  :sleepy:

 

Many people want to skip the whole loading process that a computer goes through upon startup. Some people just can't wait for their comp to start up to load their favorite program. To those people, I say... "do this":

 

Click 'Windows', on the bottom left of your Desktop.

 

At the bottom 'search' browser, type this:

C:\Users\Owner\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup

 

Or, if you're smart, copy/paste it. :P

 

Put that screen in a small state (not minimize), and drag it (by clicking and holding left-click on your mouse on the top border of the screen's window.. ) to the left side of your screen. Use the right side to single-click (left-click) a program that you want, and right-click it.

 

For example: Find Skyrim's directory @C:\Program Files (x86)\Steam\SteamApps\common\Skyrim

...change this to C:\Games\Steam\SteamApps\common\Skyrim

Get Skyrim OUT OF C:\Program Files (x86)...and into C:\Games

C:\Games is there for a very good reason...

Moving on...

 

You are now in C:\Games\Steam\SteamApps\common\Skyrim

You want MO to start every time you start your comp (even I don't go that far, but this is an example). You have your Startup program ready on the left, and your Skyrim directory on the right.

 

2 different windows.

 

On the right, target your Mod Organizer folder, and open that wonderful file. Right-click your best friend, ModOrganizer.exe, and choose 'create shortcut', and 'drag 'n drop' the .exe (shortcut) to the left. Drop it in the 'Startup' folder I had you open earlier.

 

After all of these steps have been completed, MO will now run when your comp starts.

 

I don't do this. This is an example. Maybe I should though...I do run the MO thread, afterall. ;)

 

 

Any program you target, and do this to, will run in the Startup folder, and therefore. whenever you "startup" your computer.

 

Music, and videos can be set to do the same thing.

 

 

 

 

 

I have a whole lot more coming, so stay tuned...to Batch Files and Command Prompts! :cool: I'd 'Follow' this page, if I were you... ;) 

Posted

Okay. Next, we'll cover programs that can be made using batch files.

 

You can make full-blown programs using a batch file. A batch file can be made easily, but a program using a batch file...not so much. It's all about learning. Coding.

 

You can make a batch that activates .exe files in your comp. It will "call" to programs that are already made in your comp. Also, you can make a batch that takes you to websites, and starts Youtube videos. You can even make the videos play for a set amount of time, and then switch to another video. Timed commands, is the term I'll use.

 

I will give an example of a batch running timed Youtube videos: Bruno Mars Compilation.rar

 

When you run it, it will play a video until it's finished. It will then play another video, and so on. This compilation plays 4 songs, and then finishes. Just close the page as normal when you're done watching it.

 

 

It is possible, with enough knowledge, to make a batch that runs multiple programs, that are already on your computer, using a menu that you create yourself. You need to type in the commands to your batch file to add the menu, but an example will explain better. Making a menu yourself means understanding your computer's language. If there is an error, you need to type in a prompt that tells you that, like "Error 24", or something like that. Giving your errors a number makes for much easier troubleshooting.

 

You can even defrag your computer using a batch file. It's even possible to make an anti-virus program using batch, but we're not there yet.

 

In the next example, I'll demonstrate how to run your computer's built-in programs using batch.

 

Example: HD-Tools_UK.rar

 

Do not underestimate the power of a batch file. Batch is ultimate, but you'll see that for yourself when you run HD-Tools. This one counts as complicated. No screwing around with this one. It does many things. It calls to your computer to run it's programs, and can be very useful.

 

 

 

 

 

Disclaimer

 

 

 

  • Do not upload Bruno Mars Compilation anywhere on the web

 

  • Do not upload HD-Tools anywhere on the web

 

 

 

These files are to remain here, on the one, the only...

 

logo.png

Posted

Any questions, please ask, because I need to stay on my toes, and a computer can do just about anything, if you know how to tell it to. I am more and more interested in this sort of thing by the day (especially command prompts), so asking me something I don't know will force me to learn it, and post it here, on...

 

 

Batch Files and Command Prompts . . .

Posted

Just in case you all haven't figured out how to install SDelete, here is the way that's done. You will be opening your CMD, or Command Prompt to do this. :)

 

All good IT pros know that when you delete a file in Windows, even bypassing the Recycle Bin, the data isn't removed from disk.
Instead, the file's entry in the Master File Table is marked as deleted and its clusters are freed up to store new data. That process is efficient from a disk-management point of view. But it can leave deleted files vulnerable: Unless new data wipes out all of a deleted file's clusters, that file can still be recovered. The only way to ensure that a file can't be revived is to securely overwrite all its data. One way to achieve that is by using Microsoft's free utility SDelete.
Another great tool by Mark Russinovich, a technical fellow in Microsoft's Platform and Services Division, SDelete can permanently wipe single files or directories or multiple objects by using wild cards. In addition to securely removing existing files, SDelete will purge data in unallocated clusters of a disk—that is, files that have already been deleted.
SDelete can even wipe encrypted files. When you normally delete a file protected by Windows Encrypting File System, the unencrypted contents remain behind. Use SDelete to eliminate the file instead, and the unencrypted contents are removed as well. SDelete uses the Department of Defense standard DOD 5220.22-M, which overwrites all characters of a file with a series of random new values.
To use SDelete, first download a copy, then extract the file sdelete.zip. The extracted contents include an end-user license agreement text file and sdelete.exe. No need to install—just trigger the program from its executable.
SDelete is a command-line utility, so you'll need to run it from a command prompt. Open a command window and move to the folder in which you downloaded SDelete. Typing "sdelete" at the prompt displays a list of its options, as shown in Figure 1 and below:
sdelete [-p passes] [-s] [-q] <file or directory>
sdelete [-p passes] [-z|-c] [drive letter]
-c - Zero free space (good for virtual disk optimization) [Note: This option wipes free spaces with zero values.]
-p passes - Specifies the number of overwrite passes (default is 1)
-q - Don't print errors (Quiet)
-s - Recurse subdirectories [Note: The contents of all subdirectories are included in the deletion or disk wipe.]
-z - Cleans free space [Note: this is similar to the -c option except -z uses a random string of values to more securely wipe free disk space.] AwfulArchdemon recommends this... ;) 
dd776514.fig01_L(en-us).gif
Figure 1 These options should appear when “sdelete” is typed at the command line.
Of course, you can run SDelete on the PCs in your organization yourself. But you can also make the utility available to your users. Simply create a script or batch file with the appropriate command-line options and deploy that to your users to run within Windows.
Here's a great tip I found in the Sysinternals forum: Copy your SDelete script to the Windows SendTo folder on your users' PCs. Users can then shred any file by right-clicking it, moving to the Send To command, and then selecting your script.
SDelete is compatible with Windows XP and later and Windows Server 2003 and later.

Lance Whitney is an IT consultant, software trainer and technical writer. He has spent countless hours tweaking Windows workstations and servers. Originally a journalist, he took a blind leap into the IT world back in the early '90s.

 
Posted
There are many, many things on your comp that you don't know about. I'll bet you've never seen this path: C:\Windows\System32\Drivers\etc\hosts It serves a purpose, and I'll even get into that, when I return.

 

And I meant it. ;)

 

Here is this path's purpose:

 

You may find yourself in a situation where you can't get onto a site. There can be a variety of reasons why you can't get onto this site, but you have an "override" option, and it stems from this path. You will see this:

 

 

# Copyright © 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
#      102.54.94.97     rhino.acme.com          # source server
#       38.25.63.10     x.acme.com              # x client host
 
# localhost name resolution is handled within DNS itself.
# 127.0.0.1       localhost
# ::1             localhost
 
====================================================================================================
 
If you type your IP address into this field, and then type in the name of the website you want to ALWAYS be allowed to visit, and erase any arguments your computer may have had with visiting this site in the past, then do this:
 
Example:
 
post-111270-0-51361000-1386015844_thumb.jpg
 
This tends to solve arguments your rig is having with a website not letting you log on to it. Not always though. Be sure to 'save' upon exit when you've added the necessary lines, and remember, you need to run cmd (command prompt) "as administrator" to achieve this.
 
 
 
 
Stay tuned, for more...
 
 
 
Batch Files and Command Prompts . . .

 

Posted

Also a useful tutorial. There are many, but I hope to cover it all in print...in time.

 

I like this video. It really gets you into the basics, and moves you forward quickly:

 

 

 

 

Stay tuned, for more...

 

Batch Files and Command Prompts

Posted

Good topic.

 

I have cygwin installed and whenever I need to do operations on files like batch rename or batch file move I code something up in bash. The problem is I don't do it often enough to remember what I did from session to session. Makes me go back and read up on it all over again, but I can attest to how useful it is.

 

Now a question... or request... I use Primo Ramdisk to turn part of my memory into a disk partition. The problem is, everytime it initializes, a recycle bin is created which I must manually turn off. Is there a batch file to selectively turn off (not all, just the one I want) recycle bins at startup?

 

thx,

 

 

Posted

Are you telling me it put's a second Recycle Bin on your desktop every time?

 

I suppose typing 'Rebuild', to choose your settings should work. If not, the answer lies within this link...

 

Allow me a little time, and it shall be solved, if it wasn't already. I promise. ;)

 

 

Thank you for an astute question. :)

Posted

nonono windows creates a recycle bin every time a new device is attached, which in my case is when I reboot and the ramdisk reinitializes, windows thinks it's a new partition and recreates a recycle bin on it. Then I have to disable the recycle bin manually but windows doesn't remember that setting on the next bootup.

 

Oh well, now that i've done some more digging I think this is a ramdisk thing. I guess I have to upgrade to ramdisk 5.6... but thanks anyway.

Posted

Very very interesting topic you made there, I knew the basics but I've learn a lot, usually I go for the format solution and I've fixed a lot of computers this way, some people are just careless with their computers...

Personally, I can't even stand a computer with a disorganized desktop... :P

 

I can't help you with this cause you obviously know more about it than me already, but I have a question: How powerful is Ccleaner? Does it delete properly the files and cookies and those that are already in the recycle bin?

Posted

Nope. It just empties it for you. You'll need to run Sdelete to rid yourself of the stuff that was emptied, meaning:

 

Open cmd "as administrator", and type cd C:\Program Files (x86) and press 'enter'

 

Then type sdelete -Z and press 'enter'.

 

You'll see sdelete is set for 1 pass. Just let it do it's thing until it reaches 100%, which admittedly takes a while. It takes almost as long as defrag, but not quite.

 

Personally, I can't even stand a computer with a disorganized desktop...  :P

 

You wouldn't want to see my desktop... :s I do so much stuff every day that it gets cluttered. It's looking pretty "busy". :P I really need to do something about that.

 

 

Edit: Oh, and about the other files and cookies, basically CCleaner just throws everything into your 'free space'. Sdelete zeros that space. Programs that are used to recover deleted files will be able to recover these things, if you don't use Sdelete after running CCleaner. CCleaner is really just good at getting those files out of your comp's active areas, like Program Files, etc, and somewhere they can't be used without another program's help. Sdelete is the equivalent of deleting a partition, but within chosen files only, thus permanently deleting the target(s). In this case, you would wish to target the C: free space. The term "Hanging on by a thread" comes to mind when describing deleted files using Recycle Bin alone.

  • 2 weeks later...
Posted

Downloaded the brunomars command as you suggested. will look at it later when I get the time

Your turn. Let's see a kickass YouTube vid compilation. I've always wondered what kind of music Aliens like. :P

 

 

 

 

 

Everyone else may hurry and create a quick batch, and post it here. Let's see if you've been paying attention. Any batch will do...

 

  1. ?
  2. ?
  3. ?
  4. ?
  5. ?
Posted

Following hybrid batch+java code is not mine.
I found it somewhere in i-net about 3 years ago, have no link.
 

@set @x=0 /* This line MUST be first. It hides main part of batch from JavaScript interpreter.
@echo off

::
:: Here goes batch code executing BEFORE pause
::

:: mark for repeating part of batch
:r

:: here batch evokes javascript using itself as "java", pauseing, for example, for 3 minutes (180000 milliseconds)
cscript //nologo /e:jscript "%~f0" 180000

::
:: here goes remaining part of batch
:: another pause calls - with other delay values - available too
:: cscript //nologo /e:jscript "%~f0" <anotherDelay>

:: it can be endless, or check some conditions and break, using "goto:eof"

goto r

:: Next string MUST be last. Last piece of valid batch code followed by javascript for pause.
goto:eof */ if(isFinite(WScript.Arguments(0))) WScript.Sleep(WScript.Arguments(0))

It was useful for my task - to backup current borderlands savegame.

 

@set @x=0 /* first line
@echo off

if '=='%1 (
echo parameter missed - FileName
goto :eof
)

:r
for /F "tokens=2-3 delims=:- " %%I in ('date /t') do set blTrf=%%I%%J
for /F "tokens=1-2 delims=:- " %%I in ('time /t') do set blTrf=%blTrf%%%I%%J

:: js-pause
cscript //nologo /e:jscript "%~f0" 300000
if not exist %1 goto r
for /F "tokens=2-5 delims=:- " %%I in ("%~t1") do set blSfx=%%I%%J%%K%%L
if /i %blTrf% LSS %blSfx% copy %1 "Save%blSfx%.sav" >nul
goto r

:: next line is last
goto:eof */ if(isFinite(WScript.Arguments(0))) WScript.Sleep(WScript.Arguments(0))

 

 

 

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...