Jump to content
Exit

Proposal: New subforum in Language Specific Discussion for BAT and CMD

Recommended Posts

Exit

Since BAT/CMD scripts have become a real scripting language, there should be also a subforum in the Language Specific Discussion forum.    

Just to prove the power of BAT scripts, here a licence key script.  I know there is also a working au3 solution.

@echo off
call :LicenseKeys >"%Temp%\~~%~n0.txt"
"%Temp%\~~%~n0.txt"
erase "%Temp%\~~%~n0.txt"
goto :eof

:LicenseKeys
setlocal enabledelayedexpansion
for /f "tokens=1,2*" %%i in ('reg query "HKLM\SOFTWARE\Microsoft" /reg:64 /s /v DigitalProductId  ^&^& reg query "HKLM\SOFTWARE\Wow6432Node\Microsoft" /reg:64 /s /v DigitalProductId') do (
 set t=%%i
 set t=!t:~0,5!
 if .!t!. == .HKEY_. (echo.
  call :ProductInfo "%%i %%j %%k"))
goto :eof

:ProductInfo
    setlocal enabledelayedexpansion
    set FunctionName=%~0
 echo RegistryName=%~1
 for /f "tokens=1,2*" %%i in ('reg query "%~1" /v *Product*  /reg:64') do (
  if %%i==ProductName (echo ProductName: %%k)
  if %%i==ProductId (echo ProductId: %%k)
  if %%i==ProductID (echo ProductID: %%k)
  if /I %%i==DigitalProductId (call :ProductKey "%%k"
   echo ProductKey: !ProductKey!))
 goto :eof

:ProductKey
    setlocal enabledelayedexpansion
    set FunctionName=%~0
    set RegData=%~1
    set Validchars=BCDFGHJKMPQRTVWXY2346789
 if .%RegData:~0,2%. == .A4. set HexString=%RegData:~104,30%
 if .%RegData:~0,2%. == .F8. set HexString=%RegData:~1616,30%
 for /l %%i in (0,2,28) do (set /a j=%%i/2
  set /a StringArray[!j!]=0x!HexString:~%%i,2!)
 set /a "IsWin8=(StringArray[14] & 8)/8"
 set /a "StringArray[14]=StringArray[14] - !IsWin8! * 8"
    for /l %%i in (0,1,24) do (set value=0
        for /l %%j in (14,-1,0) do (set /a value=StringArray[%%j] + !value! * 256
            set /a StringArray[%%j]="( !value! / 24 ) & 255"
            set /a value%%=24
            set /a Win8Pos=!value!)
        for %%j in (!value!) do set key=!Validchars:~%%j,1!!key!)
 If %IsWin8% == 1 (set /A "Win8Pos1=24-Win8Pos"
  set Win8Pos1=-!Win8Pos1!
  call set t1=%%key:~1,!Win8Pos!%%
  call set t2=%%key:~!Win8Pos1!%%
  set key=!t1!N!t2!)
    endlocal & set %FunctionName:~1%=%key:~0,5%-%key:~5,5%-%key:~10,5%-%key:~15,5%-%key:~20,5%
 goto :eof

May we convince the admins to create such a subforum ?

  • Like 1

My UDFs, Abbrevs and Snippets
If you like my post, just click the like button :) 

Share this post


Link to post
Share on other sites
guinness

Isn't PowerShell really meant to be replacing batch scripting?

Edited by guinness
Typo

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Share this post


Link to post
Share on other sites
Exit

Isn't PowerShell really meant to be replacing batch scripting?

Due to the default execution policy 'restriced', it is hard to execute PS-scrpts on other PCs.

But we might expand the powershell forum to also handle BAT and CMD ?


My UDFs, Abbrevs and Snippets
If you like my post, just click the like button :) 

Share this post


Link to post
Share on other sites
guinness

I would add there, as it's kind of related. I agree with @JohnOne that we don't need a sub forum for every language. I would like Java and PHP there, but am fine with C# too.


UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Share this post


Link to post
Share on other sites
Jon

Due to the default execution policy 'restriced', it is hard to execute PS-scrpts on other PCs.

But we might expand the powershell forum to also handle BAT and CMD ?

If you run it like "powershell.exe -ExecutionPolicy Bypass -File myscript.ps1" then it works fine. 

The idea was to just have the new common sexy(!) IT admin focused languages explicitly listed. Everything else can go in the general dev forum unless it warrants its own forum.

Edited by Jon
  • Like 1

Share this post


Link to post
Share on other sites
UEZ

I would suggest to add Assembler to the list because there are plenty of inline Assembler routines which are useful.

 

Thanks.

  • Like 1

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites
Skysnake

I like this idea.  And, bear in mind that bat and cmd is very close to origins of AutoIt.  GUIs are pretty and probably a whole issue all by themselves


Skysnake

Why is the snake in the sky?

Share this post


Link to post
Share on other sites
TheDcoder

I say remove all the sub-forums & use tags instead, this way we can post questions for any language, TD :P


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Spoiler

My contributions to the AutoIt Community

Some messages & Apologizes:

If I hurt you, Please accept my apologies, I never (regardless of the situation) mean to hurt anybody!!!

Also, I am very busy with my project so I will appear in the last row of the online list, if you want to contact me: Email@TheDcoder.xyz

Or you can have a nice chat with me in freenode, I use the same nick on freenode too!

3fHNZJ.gif

PLEASE JOIN ##AutoIt AND HELP THE IRC AUTOIT COMMUNITY!

Share this post


Link to post
Share on other sites
TheDcoder

@Jon Oh :o, I rarely use the search

  • Like 1

AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Spoiler

My contributions to the AutoIt Community

Some messages & Apologizes:

If I hurt you, Please accept my apologies, I never (regardless of the situation) mean to hurt anybody!!!

Also, I am very busy with my project so I will appear in the last row of the online list, if you want to contact me: Email@TheDcoder.xyz

Or you can have a nice chat with me in freenode, I use the same nick on freenode too!

3fHNZJ.gif

PLEASE JOIN ##AutoIt AND HELP THE IRC AUTOIT COMMUNITY!

Share this post


Link to post
Share on other sites
JLogan3o13

Yes, we are aware :)

  • Like 3

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
kcvinu

But learners and newbies are usually using search. :)


My Contributions

UDF Link Viewer   --- A tool to visit the links of some most important UDFs 

 Includer_2  ----- A tool to type the #include statement automatically 

 Digits To Date  ----- date from 3 integer values

PrintList ----- prints arrays into console for testing.

 Alert  ------ An alternative for MsgBox 

 MousePosition ------- A simple tooltip display of mouse position

GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function

Access_UDF  -------- An UDF for working with access database files. (.*accdb only)

 

Share this post


Link to post
Share on other sites
TheDcoder

Yes, we are aware :)

Stop teasing me :P


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Spoiler

My contributions to the AutoIt Community

Some messages & Apologizes:

If I hurt you, Please accept my apologies, I never (regardless of the situation) mean to hurt anybody!!!

Also, I am very busy with my project so I will appear in the last row of the online list, if you want to contact me: Email@TheDcoder.xyz

Or you can have a nice chat with me in freenode, I use the same nick on freenode too!

3fHNZJ.gif

PLEASE JOIN ##AutoIt AND HELP THE IRC AUTOIT COMMUNITY!

Share this post


Link to post
Share on other sites
JLogan3o13

I'd have to start, first


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
TheDcoder

@JLogan3o13 I thought that you were teasing me because I ***used to*** ask questions without searching the forums :P

 


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Spoiler

My contributions to the AutoIt Community

Some messages & Apologizes:

If I hurt you, Please accept my apologies, I never (regardless of the situation) mean to hurt anybody!!!

Also, I am very busy with my project so I will appear in the last row of the online list, if you want to contact me: Email@TheDcoder.xyz

Or you can have a nice chat with me in freenode, I use the same nick on freenode too!

3fHNZJ.gif

PLEASE JOIN ##AutoIt AND HELP THE IRC AUTOIT COMMUNITY!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×