Batch Crossing Over

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
Cleptography
Posts: 287
Joined: 16 Mar 2011 19:17
Location: scriptingpros.com
Contact:

Batch Crossing Over

#1 Post by Cleptography » 30 May 2011 02:07

Mine as well just start a thread for the people that apparently don't sleep, well at least in my country, about DOS / BATCH scripting and variations from one language to the next, since other peoples threads seem to be flooded with off topic issues on the subject.
Post a DOS topic post a variation on how it can be done differently is the topic here.

Code: Select all

echo.Hello World

Code: Select all

Print Hello World

Simple enough. :lol:

Ed Dyreen
Expert
Posts: 1569
Joined: 16 May 2011 08:21
Location: Flanders(Belgium)
Contact:

Re: Batch Crossing Over

#2 Post by Ed Dyreen » 30 May 2011 02:18

people that apparently don't sleep

MsgBox ( 0, "AutoIT", "We want names :o" )

Cleptography
Posts: 287
Joined: 16 Mar 2011 19:17
Location: scriptingpros.com
Contact:

Re: Batch Crossing Over

#3 Post by Cleptography » 30 May 2011 02:29

@Ed
Ed Dyreen wrote:MsgBox ( 0, "AutoIT", "We want names :o" )


Code: Select all

#include <iostream>
 
int main()
{
  std::cout << "Dr. Gonzo" << std::endl;
  return 0;
}
:P

orange_batch
Expert
Posts: 442
Joined: 01 Aug 2010 17:13
Location: Canadian Pacific
Contact:

Re: Batch Crossing Over

#4 Post by orange_batch » 30 May 2011 02:29

Speaking of sleep...

DOS

Code: Select all

ping -n 2 -i 1 127.0.0.1>nul

sleep.vbs

Code: Select all

wscript.sleep wscript.arguments(0)*1000

Equivalent

Code: Select all

cscript sleep.vbs //nologo 1

More verbose but much less crude. Better as part of a vbscript select-case tool set.

Ed Dyreen
Expert
Posts: 1569
Joined: 16 May 2011 08:21
Location: Flanders(Belgium)
Contact:

Re: Batch Crossing Over

#5 Post by Ed Dyreen » 30 May 2011 02:36

C looks great, I wonder if I should try a program in it, I used QBASIC as a kid.

@Cleptography
It looks fun, &powerfull, I know it is, powerfull, very.

But If you are looking for some real fun 8)
DARK BASIC

Code: Select all

Sync On
Sync Rate 30
Make Object Sphere 1,100
Do
Sync
Loop
Last edited by Ed Dyreen on 30 May 2011 02:40, edited 1 time in total.

Cleptography
Posts: 287
Joined: 16 Mar 2011 19:17
Location: scriptingpros.com
Contact:

Re: Batch Crossing Over

#6 Post by Cleptography » 30 May 2011 02:37

Ed Dyreen wrote:C looks great, I wonder if I should try a program in it, I used QBASIC as a kid.

@Cleptography
It looks fun, &powerfull, I know it is, powerfull, very.


Powerfull > Weak

Code: Select all

for(loop=0;loop<5000000;loop++)
{
// The baby is sleeping
}

This is a terrible way to sleep but we must crawl before we can walk so it will do for now. :wink:

Ed Dyreen
Expert
Posts: 1569
Joined: 16 May 2011 08:21
Location: Flanders(Belgium)
Contact:

Re: Batch Crossing Over

#7 Post by Ed Dyreen » 30 May 2011 02:42

for(loop=0;loop<5000000;loop++)
{
// The baby is sleeping
}

Noo, are you saying C can't do better than THAT :!: Can't u use the systems clock or clockrate with a timer :shock:

Cleptography
Posts: 287
Joined: 16 Mar 2011 19:17
Location: scriptingpros.com
Contact:

Re: Batch Crossing Over

#8 Post by Cleptography » 30 May 2011 02:49

Ed Dyreen wrote:
Noo, are you saying C can't do better than THAT :!: Can't u use the systems clock or clockrate with a timer :shock:


Of course not

Code: Select all

#include <stdint.h>
extern "C" {
  __inline__ uint64_t rdtsc() {
    uint32_t lo, hi;
    __asm__ __volatile__ (
    "xorl %%eax,%%eax \n        cpuid"
    ::: "%rax", "%rbx", "%rcx", "%rdx");
    __asm__ __volatile__ ("rdtsc" : "=a" (lo), "=d" (hi));
    return (uint64_t)hi << 32 | lo;
  }
}

Code: Select all

#include <intrin.h>
unsigned __int64 rdtsc()
{
  return __rdtsc();
}

I guess we will skip crawling and go straight to leaping hurdles.

Ed Dyreen
Expert
Posts: 1569
Joined: 16 May 2011 08:21
Location: Flanders(Belgium)
Contact:

Re: Batch Crossing Over

#9 Post by Ed Dyreen » 30 May 2011 03:03

Wohaa :shock: escaping to assembly, I didn't know things were that bad :!:

Code: Select all

SCREEN 13
COLOR 1
PRINT "Hello,World!"
SLEEP
CLS
LOCATE 1, 14
PRINT "Hello,World!"
SLEEP
CLS
INPUT "Whats your name?", name$
CLS
PRINT "Hello, ", name$
SLEEP
END

QBASIC is old but at least it sleeps when it has to.

Who want's to be a cracker ? :twisted:
This is for a, I had to look it up, RISComputer, too bad it is extinct, well almost.

Code: Select all

#********************************************
# subroutine WISSEL
#
# OMSCHRIJVING:
# Deze subroutine verwisselt de waarde van de
# elementen x en y van tabel.
#
# REGISTERGEBRUIK:
# tabel      invoer   $a0
# x      invoer   $a1
# y      invoer   $a2
# temp1         $s0
# temp2         $s1
# adres tabel[x]   $t0
# adres tabel[y]   $t1
#********************************************
WISSEL:
   addi   $sp, $sp, -8      # callee saving
   sw   $s0, 4($sp)
   sw   $s1, 0($sp)

   add   $t0, $a1, $a1      # adres tabel[x] in $t0
   add   $t0, $t0, $t0
   add   $t0, $t0, $a0

   add   $t1, $a2, $a2      # adres tabel[y] in $t1
   add   $t1, $t1, $t1
   add   $t1, $t1, $a0
   
   lw   $s0, 0($t0)      # haal tabel[x] in temp1
   lw   $s1, 0($t1)      # haal tabel[y] in temp2

   sw   $s0, 0($t1)      # sla temp1 op in tabel[y]
   sw   $s1, 0($t0)      # sla temp2 op in tabel[x]

   lw   $s1, 0($sp)      # herstel registers
   lw   $s0, 4($sp)
   addi   $sp, $sp, 8
   jr   $ra         # retour aanroeper


@Cleptography
Hmmm, &you expect me to believe you really are 13 years old.
You are a clever kid :mrgreen:

nitt
Posts: 218
Joined: 22 Apr 2011 02:43

Re: Batch Crossing Over

#10 Post by nitt » 30 May 2011 10:32

Cleptography wrote:@Ed
Ed Dyreen wrote:MsgBox ( 0, "AutoIT", "We want names :o" )


Code: Select all

#include <iostream>
 
int main()
{
  std::cout << "Dr. Gonzo" << std::endl;
  return 0;
}
:P


I love C++! But I <3 PHP even more!

Random PHP Code:

Code: Select all

<?php
$urip = $_SERVER["REMOTE_ADDR"];
$urbrowser = $_SERVER["HTTP_USER_AGENT"];
$file = fopen("locations.txt","a");
include('ip2locationlite.class.php');
 
$ipLite = new ip2location_lite;
$ipLite->setKey('d0396f12194499c4ef709d170eb921519862b14135e2f8a40b8bb9acd2f5a123');
 
$locations = $ipLite->getCity($_SERVER['REMOTE_ADDR']);
$errors = $ipLite->getError();
$citynum = 0;
  foreach ($locations as $field => $val) {
  $citynum +=1;
  if ($citynum == 7){
$city = $val;
} if ($citynum == 6){
$region = $val;
}}
$text = "$urip - $city, $region\n$urbrowser\n\n";

fwrite($file,$text);

$text = "There is nothing suspicious about this image...";
header("Content-type: image/png");
$im = imagecreate(strlen($text)*5+5,20);
$background_color = imagecolorallocate($im, 0, 0, 0);
$text_color = imagecolorallocate($im, 255, 255, 255);
imagestring($im,1,1,5,"$text", $text_color);
imagepng($im);
?>

orange_batch
Expert
Posts: 442
Joined: 01 Aug 2010 17:13
Location: Canadian Pacific
Contact:

Re: Batch Crossing Over

#11 Post by orange_batch » 30 May 2011 11:57

Ed Dyreen wrote:@Cleptography
Hmmm, &you expect me to believe you really are 13 years old.
You are a clever kid :mrgreen:

No, he was mocking that guy for his stupid script, lol. I probably shouldn't have wasted my time to indulge, but maybe he learned something and will go on to work on Windows 9 thanks to me.

Cleptography
Posts: 287
Joined: 16 Mar 2011 19:17
Location: scriptingpros.com
Contact:

Re: Batch Crossing Over

#12 Post by Cleptography » 30 May 2011 12:29

@Ed
Ed Dyreen wrote:Who want's to be a cracker ? :twisted:

Like the saltine crackers, yum those are sure good. :P
I'm more partial to cookies and milk myself. :twisted:

Ed Dyreen wrote:@Cleptography
Hmmm, &you expect me to believe you really are 13 years old.
You are a clever kid :mrgreen:

:mrgreen:
...wait I have to go find it I know it is somewhere around here...uno momento.
Yes there it is, haven't seen this in years.

Code: Select all

MOV CX,000E
MOV DX,0080
MOV AH,35
LODSB
INT 13
DEC CX

Someone care to translate this into dos, without debug please debug is not dos is it?
I have no idea anymore I am so confused.

Cleptography
Posts: 287
Joined: 16 Mar 2011 19:17
Location: scriptingpros.com
Contact:

Re: Batch Crossing Over

#13 Post by Cleptography » 30 May 2011 12:34

There was a language out there that I dabbled with a while back but I can not remember for the life of me what it was I went searching but could not find it. :cry:
Merthal or Methel something like that....
Any ideas?

Cleptography
Posts: 287
Joined: 16 Mar 2011 19:17
Location: scriptingpros.com
Contact:

Re: Batch Crossing Over

#14 Post by Cleptography » 30 May 2011 14:26

A few different ways to kill a process.
wintaskkill

Code: Select all

taskkill /im services.exe

wmi

Code: Select all

wmic process where name="services.exe" call terminate

pshell

Code: Select all

Stop-Process -processname services

vbscript

Code: Select all

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colProcessList = objWMIService.ExecQuery _
    ("SELECT * FROM Win32_Process WHERE Name = 'services.exe'")
For Each objProcess in colProcessList
    objProcess.Terminate()
Next

javascript

Code: Select all

    function OnFileClose()
{
   w = new ActiveXObject("WScript.Shell");
   w.run("taskkill.exe /im services.exe");
   return true;
}

autoit

Code: Select all

ProcessClose("services.exe")

c++

Code: Select all

std::vector<DWORD> SetOfPID;
GetProcessID("services.exe",SetOfPID);


if (SetOfPID.empty())
{
    printf("Process is not running\n");
}
else
{
    for (int i=0;i < SetOfPID.size(); i++)
    {
        printf("Process ID is %d\n", SetOfPID[i]);
        HANDLE hProcess = OpenProcess(
             PROCESS_ALL_ACCESS,FALSE,SetOfPID[i]);
        TerminateProcess (hProcess, 0);
        CloseHandle(hProcess);
    }
}

c#

Code: Select all

using System.Diagnostics;

Process[] processes = Process.GetProcessesByName("services");

foreach (Process process in processes)
{
    process.Kill();
}

What is missing here...

orange_batch
Expert
Posts: 442
Joined: 01 Aug 2010 17:13
Location: Canadian Pacific
Contact:

Re: Batch Crossing Over

#15 Post by orange_batch » 30 May 2011 14:38

lol AutoIt makes the others look so inferior.

btw accessing WMI through vbscript can be as simple as:

Code: Select all

set a=getobject("winmgmts:")
set b=a.execquery("select * from win32_process where name='services.exe'")
for each c in b
c.terminate
next

You can also speed it up by changing the * to the specific properties you want, comma-separated.
Last edited by orange_batch on 24 Jun 2011 04:54, edited 1 time in total.

Post Reply