Jump to content

Recommended Posts

Posted

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 ?

App: Au3toCmd              UDF: _SingleScript()                             

Posted (edited)

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

Posted

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 ?

App: Au3toCmd              UDF: _SingleScript()                             

Posted

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

  • Administrators
Posted (edited)

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
  • 1 month later...
Posted

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?

Posted

But learners and newbies are usually using search. :)

Spoiler

My Contributions

Glance GUI Library - A gui library based on Windows api functions. Written in Nim programming language.

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)

 

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
  • Recently Browsing   0 members

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