Jump to content

MHz

Member
  • Posts

    1,691
  • Joined

  • Last visited

  • Donations

    0.00 USD 
  • Country

    Australia

Posts posted by MHz

  1. shorterxp,

    DT 3.46 setup is an executable which extracts an msi file to the %temp% directory.

    To get the msi:

     * Execute DT executable.

     * Click Install button.

     * Look in %temp% folder for an msi file with approximately 5 numbers or letters and a size of 813 KB.

     * Copy the msi file and rename the copy to something more meaningful.

     * Cancel the install.

    You can now use the msi file with arguments like /qn to perform a install silent.

    DT 4 is quite different and needs to be handled by a different method.

  2. Suitable compile directives added and added #RequireAdmin directive if run as not compiled. Scripts are still based on SlowView version 1.0 released in 2003.

    Silent Script:

    slowview_silent_updated.au3

    Automated script:

    slowview_auto_updated.au3

    Setting the variable $do_not_create_shortcuts to True will avoid creating shortcuts and thus no folder created in the Start Menu. If True, checks the "Do not create shortcuts" checkbox.

    Setting $move_wizard_window to False will not move the 2nd wizard window off the main screen.

    This script below has a fix for missing uninstall entries when selecting no shortcuts.

    slowview_auto_updated_uninstall_fix.au3

    Installer:

    Get from brennig.com

    SlowView 1.0 - (January 2003, works on Windows 95/98/NT and newer)

  3. As said I was just kidding, without any intention to offend, nor to insult anyone or anything.

    I'm really really sorry, I apologise unreservedly. I take it back and offer a complete and utter retraction. The imputation was totally without basis in fact, and was in no way fair comment, and was motivated purely by malice, and I deeply regret any distress that my comments may have caused you, or your family, and I hereby undertake not to repeat any such slander at any time in the future.

     

    Is this OK with you?

    Your 1st line seems original. A person, like yourself, saying something and then using a contradiction will always be quite disturbing. This seems like a recurring pattern for you. Using a method of insult and then using a just kidding, but ..., however ..., and any other alternation does not hide the insult.

     

    To use a copy and paste of a movie quote used by Archie from the movie "The Fish called Wanda" is quite disingenious. So is the copy and pasted quote OK with me? I am not sure how to score such a non genuine statement from you. Silliness with the movie quote does not pass as sincere regret to me. I guess the joke is on me.

     

    However, to be picky and just for the record, MS-DOS 7.1 (though it includes Qbasic alright) is not a complete OS, it is part of some Windows operating systems, (namely Windows 95 OSR 2, Windows 95 OSR 2.5, Windows 98, and Windows 98 SE).

    MS-DOS exists in the Win 9x OSes as mentioned here. It details of how to boot into MS-DOS. So, it existed in Win 9x in one form or another and most possibly complies as an OS. So, as MS-DOS in 9x as being not a complete OS in its own right is very much in doubt considering an OS can be almost any operating environment.

  4.  

    jaclaz,

     

    QBasic is a part of MS-DOS 7.1 and offers a prompt. So, a nice try. Besides, VBScript did not exist in the era of MS-DOS AFAIK. Not much did exist for Microsoft at that time. Hard times then and I do not miss it. The more a programming language can do, the more flexible I find in using it. MS-DOS was/is differcult because of its limitations.

    Sure :), I was referring to the "usual plot" :

    http://www.msfn.org/board/topic/173609-btach-set-vast-with-echo-doesnt-work/#entry1096004

    just kidding....

     

    jaclaz

     

    I accept it as an insult else why the link? MS-DOS is a complete OS and QBasic is a part of it as I already mentioned. The comparison to batch is rather dry for my taste. Nice try again.

  5. jaclaz,

     

    QBasic is a part of MS-DOS 7.1 and offers a prompt. So, a nice try. Besides, VBScript did not exist in the era of MS-DOS AFAIK. Not much did exist for Microsoft at that time. Hard times then and I do not miss it. The more a programming language can do, the more flexible I find in using it. MS-DOS was/is differcult because of its limitations.

     

    Edit: Hmm, typing Microsoft adds a link to the Microsoft store. Such irony.

  6. A little more advanced BASIC was to use QBasic.

     

    Example test.bat could use:

    C:\DOS71\QBASIC /run test.bas

    and test.bas in which QBasic interprets could use:

    REM Get the users input.INPUT "Enter the system Serial Number"; reply$REM Show the value of the reply.PRINT reply$REM Return to the system.SYSTEM

    Some examples shown in this PDF on page 14 for retrieving input from the user in QBasic. If you wanted the bas file compiled then the MS-DOS compatible version of FreeBasic could be used.

     

  7. Here are some specs gathered for your PC2 mainboards.

    The ASRock mainboard has various versions. Later versions are Gigabyte LAN. If you have version 1.0 or 2.0, then no Gigabyte LAN.

    http://www.asrock.com/mb/NVIDIA/ALiveNF7G-HD720p%20R1.0/

    - Realtek PHY RTL8201CL

    - Speed: 10/100 Ethernet

    - Supports Wake-On-LAN

    - Supports PXE

    http://www.asrock.com/mb/NVIDIA/ALiveNF7G-HD720p%20R2.0/

    - Realtek PHY RTL8201CL

    - Speed: 10/100 Ethernet

    - Supports Wake-On-LAN

    - Supports PXE

    http://www.asrock.com/mb/NVIDIA/ALiveNF7G-HD720p%20R3.0/

    - Gigabit LAN 10/100/1000 Mb/s

    - Giga PHY Realtek RTL8211B

    - Supports Wake-On-LAN

    - Supports PXE

    http://www.asrock.com/mb/NVIDIA/ALiveNF7G-HD720p%20R5.0/

    - Gigabit LAN 10/100/1000 Mb/s

    - Giga PHY RTL8211B

    - Supports Wake-On-LAN

    - Supports PXE

    The MSI mainboard is mentioned as Gigabyte though mentions at the bottom of the page that specs vary depending on area... , so could have different versions.

    http://msi.com/product/mb/880GMA-E45.html#hero-specification

    - Realtek PCI-E GbLAN controller 8111DL

    - Integrated Fast Ethernet MAC and PHY in single chip

    - Supports 10Mb/s, 100Mb/s and 1000Mb/s

    - Compliance with PCI-Express Bus specification v1.0a

    These mainboards may have settings for the LAN speed in the Bios though I would expect 1000Mb/s as default.

    Cat 5E cables are regarded as good for Gigabyte LAN.

    If your Router is saying that the LAN adapter is 100Mb/s and you are sure it is a Gigabyte, then I would check if a Bios update is available. Check for a LAN and chipset updated drivers.

  8. Problem is: I now have to decide, how much of this files I really like to change

    Depends on how much you can do by script. Manually doing it would be a PITA.

     

    ... I although would need something like a "Codepage Detector", who checks up if first, if the file can be cleaned; - by searching the first byte somehow ?

    Codepage affects the extended ASCII. This depends on the system language default that is set. It is not a BOM that defines codepage, but rather file encoding. If you look at the _FileWrite() function, you may noticed that I used FileGetEncoding() which gets the encoding that the file uses.

     

    @ECHO OFF & COLOR 3F & ECHO Script by msfn User: MHZif not exist subfolder md subfolderfor %%A in (*.adm; *.adr; *.asa; *.asp; *.aspx; *.bat; *.cer; *.cf; *.chs; *.cht; *.cmd; *.cnt; *.config; *.cpx; *.crl; *.css; *.csv; *.default; *.df; *.dns; *.dtd; *.dun; *.dxt; *.ecf; *.eng; *.gpd; *.h; *.h2; *.hex; *.hht; *.hkf; *.hpj; *.hta; *.htm; *.htt; *.htx; *.hxx; *.icw; *.inc; *.inf; *.ini; *.ins; *.isp; *.jpn; *.js; *.key; *.kor; *.man; *.manifest; *.mfl; *.mib; *.mof; *.msc; *.nt; *.obe; *.osc; *.p7b; *.pmc; *.ppd; *.ppt; *.pro; *.prx; *.rat; *.reg; *.rsp; *.sam; *.sed; *.sep; *.set; *.sif; *.smc; *.sp2; *.spd; *.sql; *.srg; *.sym; *.tha; *.the; *.txt; *.uninstall; *.url; *.vbs; *.vcf; *.ver; *.wpl; *.wsc; *.wsx; *.xdr; *.xml; *.xsd; *.xsl; *.xslt) do reformatini.exe "%%~A" "subfolder\%%~nxA"Pause
    I do not know probably half of those extensions and whether it is safe to use the Regular Expressions on those as they are designed for an ini file type structure. You may need to make Regular Expressions in different functions to be called by the detected file type.
  9. Have a look here. At least in Windows 7 is where your themes are saved.

    %LocalAppData%\Microsoft\Windows\Themes

    Try customizing your theme in the Personalization panel, save it and then look at that path in Explorer. This may give your a theme that has been processed by the Personalization panel process. I have no understanding of your dll or the msstyles files and thus is out of my scope.

  10. You should be able to use *.* as first parameter and a folder as 2nd parameter. This is so long as you have only text based files in the source directory as no file type filtering is done by the script.
     
    Another way could be to rename the files adding a temporary extension i.e. file1.ini to file1.ini.text, file2.inf to file2.inf.text etc. Do a reformatini.exe *.text destfolder and then once done, rename the files removing the temporary extension. CMD For loop and using Rename should be able to do the mass file renaming.

     

    As for some whitespace which could be removed. The ini file format usually is not so spacious in its default API usage.

     

    i.e. Try this test. Requires reformatini.exe for the comparison.

    ; Create a default ini layout.IniWrite('test1.ini', 'section 1', 'key1', 'value1')IniWrite('test1.ini', 'section 1', 'key2', 'value2')IniWrite('test1.ini', 'section 2', 'key1', 'value1')IniWrite('test1.ini', 'section 2', 'key2', 'value2'); Clean the ini.RunWait('reformatini.exe test1.ini test2.ini'); Read the characters of the files into a variable.$test1 = FileRead('test1.ini')$test2 = FileRead('test2.ini'); Show some results.MsgBox(0x40000, @ScriptName, _ 'Size of test1 = ' & StringLen($test1) & @CRLF & @CRLF & _ $test1 & @CRLF & @CRLF & _ 'Size of test2 = ' & StringLen($test2) & @CRLF & @CRLF & _ $test2 & @CRLF _)

    I get this output.

    Size of test1 = 78[section 1]key1=value1key2=value2[section 2]key1=value1key2=value2Size of test2 = 88[section 1]key1 = value1key2 = value2[section 2]key1 = value1key2 = value2

    10 characters are excess whitespace in the cleanup file as it adds spaces around the = character and adds spacing before section name lines. Something to consider. Minor changes to the Regular Expressions can change that result.

  11. <snip>

    Update: After some testing of your code i found a entry that seems to clean some other codepage tabs/spaces) - just dont know why it begins with (  and get the & @ in a little different order

     

    	$sContent = (StringRegExpReplace($sContent, "\h+", " ") & @CRLF)

    The extra braces is forcing everything within them to be evaluated. In that example, they serve no meaningful purpose. Take care with something like that pattern as paths in your text files can have multiple spaces or tabs as an example which could break those paths.

     

    Adding (*UCP) at the beginning of each Regular Expression pattern may change the behavior of how certain characters are matched. I.e. \h may match unicode horizontal spaces as well as the ASCII + Extended ASCII horizontal spaces.

     

    So you can change this function to:

    Func _CleanIniFileContent($sContent)	; Trim whitespace from the end of each line.	$sContent = StringRegExpReplace($sContent, '(*UCP)(?m)^\h*(.+?)\h*$', '\1')	; Remove horizonal whitespace on lines that have no other content.	$sContent = StringRegExpReplace($sContent, '(*UCP)(?m)^\h+$', '\1')	; Remove empty lines.	$sContent = StringRegExpReplace($sContent, '(*UCP)(\r\n|\n){2,}', '\1')	; Fix the spacing between the key values and the data values.	$sContent = StringRegExpReplace($sContent, '(*UCP)(?m)^([^;#[])(.*?)\h*=\h*(.*)$', '\1\2 = \3')	; Trim the spacing from the quoted data values. i.e. " string " to "string".	$sContent = StringRegExpReplace($sContent, '(*UCP)(?m)^([^;#[])(.+?) = "\h*(.+?)\h*"$', '\1\2 = "\3"')	; Add empty lines before section names.	$sContent = StringRegExpReplace($sContent, '(*UCP)(?m)^(\[.+\])$', @CRLF & '\1')	; Trim both ends of the content.	$sContent = StringStripWS($sContent, 0x3)	Return $sContentEndFunc

    This is untested so it may work OK or it may need to be updated to handle the different behavior.

     

    Edit1: Added extra info about using just \h+ in a pattern.

     

    Edit2: Created another version. v1.1. See below.

     

    Due to approximately 1200 files you have, running a process 1200 times in a loop is rather harsh IMO.

    A test is done in this version on the 2nd parameter and if it is an existing directory path then you can use a file pattern on the 1st parameter. Thus, one process can do multiple files.

     

    A 7th test was added to the test CMD file to show this:

    echo ### Test 7: reformatini.exe *.ini dest.if not exist dest md destreformatini.exe *.ini dest

    The AutoIt script is here:

    ; Name of compiled file.#pragma compile(Out, 'reformatini.exe'); CUI program. Set to False for a GUI program.#pragma compile(Console, True); Bit x86|x64. Set to true for 64 bit program.#pragma compile(x64, False); AutoIt version. Tested on this version.#pragma compile(FileVersion, 3.3.10.2); What this file is meant for.#pragma compile(FileDescription, 'Reformat ini file content. Use /?, -? or -h for help.'); A name for the program.#pragma compile(ProductName, 'Ini File Reformat Tool'); Version for this program.#pragma compile(ProductVersion, 1.1.0.0)#NoTrayIconIf $CMDLINE[0] > 2 Then	; More then 2 parameter is not supported.	ConsoleWriteError('Only maximum of 2 parameters is allowed.' & @CRLF)	Exit 1	ElseIf $CMDLINE[0] = 2 Then	If StringInStr(FileGetAttrib($CMDLINE[2]), 'D') Then		; Destination is a directory path.				; Get a handle to the 1st file.		$hFind = FileFindFirstFile($CMDLINE[1])		If $hFind = -1 Then			ConsoleWriteError('Failed to find the source file.' & @CRLF)			Exit 5		EndIf				; Get the source directory as we need to read the source files from there.		$sSourceDir = StringRegExpReplace($CMDLINE[1], '^(.+)\\.*?$', '\1')		If Not @extended Then $sSourceDir = '.'				While 1			; Find a file that matches the pattern.			$sFound = FileFindNextFile($hFind)			If @error Then ExitLoop						; Skip folders.			If @extended Then ContinueLoop									; Give some feedback of file processing.			ConsoleWrite('Processing "' & $sSourceDir & '\' & $sFound & '"' & @CRLF)						; Read direct from the ini file.			$sContent = _FileRead($sSourceDir & '\' & $sFound, True)			If @error Then				FileClose($hFind)				Exit 2			EndIf						; Clean the content from the ini file.			$sNewContent = _CleanIniFileContent($sContent)						; Write to the output file.			_FileWrite($sSourceDir & '\' & $sFound, $CMDLINE[2] & '\' & $sFound, $sNewContent, True)			If @error Then				FileClose($hFind)				Exit 4			EndIf						Sleep(10)		WEnd				; Close the find handle.		FileClose($hFind)			Else		; Give some feedback of file processing.		ConsoleWrite('Processing "' & $CMDLINE[1] & '"' & @CRLF)				; Read direct from the ini file.		$sContent = _FileRead($CMDLINE[1])				; Clean the content from the ini file.		$sNewContent = _CleanIniFileContent($sContent)				; Write to the output file.		_FileWrite($CMDLINE[1], $CMDLINE[2], $sNewContent)	EndIf	ElseIf $CMDLINE[0] = 1 Then	Switch $CMDLINE[1]		Case '/?', '-?', '-h'			; Help			ConsoleWrite( _			 'Ini File Reformat Tool' & @CRLF & _			 'Outputs the reformatted content to the console or to a file.' & @CRLF & @CRLF & _			 'Pass 2 parameters as 1st being path to the source file and 2nd' & @CRLF & _			 'to the destination file. The file encoding of the destination file' & @CRLF & _			 'will be based on the source file encoding. If the 2nd is a directory' & @CRLF & _			 'path, then the 1st can be a pattern to find and process multiple files.' & @CRLF & _			 ' i.e. "' & @ScriptName & '" source.ini destination.ini' & @CRLF & _			 ' i.e. "' & @ScriptName & '" *.ini "destination folder"' & @CRLF & @CRLF & _			 'Or, pass 1 parameter as being the path to the source file.' & @CRLF & _			 ' i.e. "' & @ScriptName & '" source.ini' & @CRLF & @CRLF & _			 'Or, pipe to this file.' & @CRLF & _			 ' i.e. Type source.ini | "' & @ScriptName & '"' & @CRLF & @CRLF & _			 'Exitcode:' & @CRLF & _			 ' 1 Only maximum of 2 parameters is allowed.' & @CRLF & _			 ' 2 Failed to read the file.' & @CRLF & _			 ' 3 No parameters and no input provided.' & @CRLF & _			 ' 4 Failed to open the file for write.' & @CRLF & _			 ' 5 Failed to find the source file.' & @CRLF _			)					Case Else			; Read direct from the ini file.			$sContent = _FileRead($CMDLINE[1])						; Clean the content from the ini file.			$sNewContent = _CleanIniFileContent($sContent)						; Just output the new content to console.			ConsoleWrite($sNewContent & @CRLF)	EndSwitch	Else	; Read from stdin.	$sContent = ''	Do		Sleep(10)		$sContent &= ConsoleRead()	Until @error		If $sContent == '' Then		ConsoleWriteError('No parameters and no input provided.' & @CRLF)		Exit 3	EndIf		; Clean the content from the ini file.	$sNewContent = _CleanIniFileContent($sContent)		; Just output the new content to console.	ConsoleWrite($sNewContent & @CRLF)	EndIfExitFunc _CleanIniFileContent($sContent)	Local $sPrefix	; Add a PCRE prefix here i.e. '(*UCP)' for full unicode support.	$sPrefix = '(*UCP)'	; Trim whitespace from the end of each line.	$sContent = StringRegExpReplace($sContent, $sPrefix & '(?m)^\h*(.+?)\h*$', '\1')	; Remove horizonal whitespace on lines that have no other content.	$sContent = StringRegExpReplace($sContent, $sPrefix & '(?m)^\h+$', '\1')	; Remove empty lines.	$sContent = StringRegExpReplace($sContent, $sPrefix & '(\r\n|\n){2,}', '\1')	; Fix the spacing between the key values and the data values.	$sContent = StringRegExpReplace($sContent, $sPrefix & '(?m)^([^;#[])(.*?)\h*=\h*(.*)$', '\1\2 = \3')	; Trim the spacing from the quoted data values. i.e. " string " to "string".	$sContent = StringRegExpReplace($sContent, $sPrefix & '(?m)^([^;#[])(.+?) = "\h*(.+?)\h*"$', '\1\2 = "\3"')	; Add empty lines before section names.	$sContent = StringRegExpReplace($sContent, $sPrefix & '(?m)^(\[.+\])$', @CRLF & '\1')	; Trim both ends of the content.	$sContent = StringStripWS($sContent, 0x3)	Return $sContentEndFuncFunc _FileRead($sSourceFile, $bReturnOnError = False)	; Read direct from the ini file.	Local $sContent	$sContent = FileRead($sSourceFile)	If @error Then		ConsoleWriteError('Failed to read the file "' & $sSourceFile & '".' & @CRLF)		If $bReturnOnError Then Return SetError(1, 0, 2)		Exit 2	EndIf	Return $sContentEndFuncFunc _FileWrite($sSourceFile, $sDestinationFile, $sContent, $bReturnOnError = False)	; Open the output file for erase and then write in the same encoding as the source file.	Local $hWrite	$hWrite = FileOpen($sDestinationFile, FileGetEncoding($sSourceFile) + 0x2)	If $hWrite = -1 Then		ConsoleWriteError('Failed to open the file for write.' & @CRLF)		If $bReturnOnError Then Return SetError(1, 0, 4)		Exit 4	Else		; Write the new content to the output file.		FileWrite($hWrite, $sContent & @CRLF)		FileClose($hWrite)	EndIfEndFunc

     It already has the (*UCP) prefix on the Regular Expressions if you look at the _CleanIniFileContent() function.

  12. Reshacker, hmm, not 64 bit compatible AFAIK. A shame really as it is renowned as being such a great program in its prime time. Even good programmers and their programs may need to retire.

     

    I will try your "MasterCode" for all that files next days... ;) (I have tryed to open all 1200 Files with Ultraedit by hand to modify them, and sometimes i got a warning, that this file is not dos coded - but i can fix that files before - I just have to make a list...)

    Cool. 1200 files, major BLEEP! By the time you have edited a couple of dozen or so, you could have a script to do the rest in seconds. Yeah, yeah, yeah, takes some known knowledge,though something to strive for. If Ultraedit is complaining about not being a DOS coded file then perhaps it thinks it is a binary file. A plain text file does not have a header yet alone a DOS header. Something strange may be going on there.

  13.  

    First: Thanks a Lot: MHZ - your Script work perfectly, now I just need do modify it a bit, - or the batch with something like %1, to change an amount of Files in a Folder...
     
    - Second:  I am Sure that a Perl Script can do it easily, - but I am not a programmer (I use try and error method instead...) - and wasn't able to combine those Expressions for the end and begin of a line...
    ...

    Your welcome.

    I made it as a CUI i.e. console program so it can be used in a CMD script something like:

    if not exist subfolder md subfolderfor %%A in (*.ini) do reformatini.exe "%%~A" "subfolder\%%~nxA"

    Actually, you could do the above with it compiled as a GUI program though you would get no output in the CMD window.

     

    Look, I do not expect you to be a (professional,serious,whatever) programmer. Learning programming is like climbing a ladder. You go step by step. The rate of the climb is up to you. Do it as steep as you can handle. What I have learnt is not by magic but determination. You can probably be there one day. About regular expressions, I considered I could do it in 1 regular expression, I come close, but kept failing. So, bleep it, I did it over several expressions. Maybe not the best but got it done and if a bug is present then usually I can track it down to one of the expressions or needing another expression. PCRE may need unicode i.e. UCP turned on though I do not handle unicode characters in the patterns so hopefully it should not be needed. If I sound a little too advanced for you then say, hey, can you break this down. I will try though I may have lost some prior memory but I can only try to remember how I knew little about programming i.e. I may need to be reminded. :)

  14. Certainly something with Regular Expression support is suitable. Surprised that Perlscript cannot do it. But hey, AutoIt has Perl Compatible Regular Expression support ;).

     

    This is what I came up with. Many here seem to like using CMD scripts so I made this AutoIt script to be compiled as a CUI program. I am using AutoIt 3.3.10.2 at present which should be compatible with the latest version.

    ; Name of compiled file.#pragma compile(Out, 'reformatini.exe'); CUI program. Set to False for a GUI program.#pragma compile(Console, True); Bit x86|x64. Set to true for 64 bit program.#pragma compile(x64, False); AutoIt version. Tested on this version.#pragma compile(FileVersion, 3.3.10.2); What this file is meant for.#pragma compile(FileDescription, 'Reformat ini file content. Use /?, -? or -h for help.'); A name for the program.#pragma compile(ProductName, 'Ini File Reformat Tool'); Version for this program.#pragma compile(ProductVersion, 1.0.0.0)#NoTrayIconIf $CMDLINE[0] > 2 Then	; More then 1 parameter is not supported.	ConsoleWriteError('Only maximum of 2 parameters is allowed.' & @CRLF)	Exit 1ElseIf $CMDLINE[0] = 2 Then	; Read direct from the ini file.	$sContent = FileRead($CMDLINE[1])	If @error Then		ConsoleWriteError('Failed to read the file.' & @CRLF)		Exit 2	EndIfElseIf $CMDLINE[0] = 1 Then	Switch $CMDLINE[1]		Case '/?', '-?', '-h'			; Help			ConsoleWrite( _			 'Ini File Reformat Tool' & @CRLF & _			 'Outputs the reformatted content to the console or to a file.' & @CRLF & @CRLF & _			 'Pass 2 parameters as 1st being path to the source file and 2nd' & @CRLF & _			 'to the destination file. The file encoding of the destination file' & @CRLF & _			 'will be based on the source file encoding.' & @CRLF & _			 ' i.e. "' & @ScriptName & '" source.ini destination.ini' & @CRLF & @CRLF & _			 'Or, pass 1 parameter as being the path to the source file.' & @CRLF & _			 ' i.e. "' & @ScriptName & '" source.ini' & @CRLF & @CRLF & _			 'Or, pipe to this file.' & @CRLF & _			 ' i.e. Type source.ini | "' & @ScriptName & '"' & @CRLF & @CRLF & _			 'Exitcode:' & @CRLF & _			 ' 1 Only maximum of 2 parameters is allowed.' & @CRLF & _			 ' 2 Failed to read the file.' & @CRLF & _			 ' 3 No parameters and no input provided.' & @CRLF & _			 ' 4 Failed to open the file for write.' & @CRLF _			)			Exit		Case Else			; Read direct from the ini file.			$sContent = FileRead($CMDLINE[1])			If @error Then				ConsoleWriteError('Failed to read the file.' & @CRLF)				Exit 2			EndIf	EndSwitchElse	; Read from stdin.	$sContent = ''	Do		$sContent &= ConsoleRead()	Until @error	If $sContent == '' Then		ConsoleWriteError('No parameters and no input provided.' & @CRLF)		Exit 3	EndIfEndIf; Clean the content from the ini file.$sNewContent = _CleanIniFileContent($sContent); Output the cleaned content.If $CMDLINE[0] = 2 Then	; Open the output file for erase and then write in the same encoding as the source file.	$hWrite = FileOpen($CMDLINE[2], FileGetEncoding($CMDLINE[1]) + 0x2)	If $hWrite = -1 Then		ConsoleWriteError('Failed to open the file for write.' & @CRLF)		Exit 4	Else		; Write the new content to the output file.		FileWrite($hWrite, $sNewContent & @CRLF)		FileClose($hWrite)	EndIfElse	; Just output the new content to console.	ConsoleWrite($sNewContent & @CRLF)EndIfExitFunc _CleanIniFileContent($sContent)	; Remove empty lines and trim whitespace from the end of each line.	$sContent = StringRegExpReplace($sContent, '(?m)^\h*(.+?)\h*$', '\1')	; Remove horizonal whitespace on lines that have no other content.	$sContent = StringRegExpReplace($sContent, '(?m)^\h+$', '\1')	; Remove empty lines.	$sContent = StringRegExpReplace($sContent, '(\r\n|\n){2,}', '\1')	; Fix the spacing between the key values and the data values.	$sContent = StringRegExpReplace($sContent, '(?m)^([^;#[])(.*?)\h*=\h*(.*)$', '\1\2 = \3')	; Trim the spacing from the quoted data values. i.e. " string " to "string".	$sContent = StringRegExpReplace($sContent, '(?m)^([^;#[])(.+?) = "\h*(.+?)\h*"$', '\1\2 = "\3"')	; Add empty lines before section names.	$sContent = StringRegExpReplace($sContent, '(?m)^(\[.+\])$', @CRLF & '\1')	; Trim both ends of the content.	$sContent = StringStripWS($sContent, 0x3)	Return $sContentEndFunc

    Here is a cmd script used to test it and the output.

    CMD script to test the compiled AutoIt script named reformatini.exe.

    @echo offecho ### Test 1: reformatini.exe -h.reformatini.exe -hecho ### Test 2: type source.ini.type source.iniecho ### Test 3: type source.ini ^| reformatini.exe.type source.ini | reformatini.exeecho ### Test 4: reformatini.exe source.ini.reformatini.exe source.iniecho ### Test 5: reformatini.exe source.ini destination.ini.reformatini.exe source.ini destination.iniecho ### Test 6: reformatini.exe source.ini ^> destination_echoed.ini.reformatini.exe source.ini > destination_echoed.inipausegoto :eof

    Output in the CMD window.

    ### Test 1: reformatini.exe -h.Ini File Reformat ToolOutputs the reformatted content to the console or to a file.Pass 2 parameters as 1st being path to the source file and 2ndto the destination file. The file encoding of the destination filewill be based on the source file encoding. i.e. "reformatini.exe" source.ini destination.iniOr, pass 1 parameter as being the path to the source file. i.e. "reformatini.exe" source.iniOr, pipe to this file. i.e. Type source.ini | "reformatini.exe"Exitcode: 1 Only maximum of 2 parameters is allowed. 2 Failed to read the file. 3 No parameters and no input provided. 4 Failed to open the file for write.### Test 2: type source.ini.; Generated by ERROR[Data]        AutomaticUpdates= " No"  Autopartition =0        MsDosInitiated  = 0         UnattendedInstall      =" 2 + 4 "[Unattended]                                UnattendMode=                           FullUnattendedProgramFilesDir="\Program Files (x86)"NoWaitAfterGUIMode=1 ### Test 3: type source.ini | reformatini.exe.; Generated by ERROR[Data]AutomaticUpdates = "No"Autopartition = 0MsDosInitiated = 0UnattendedInstall = "2 + 4"[Unattended]UnattendMode = FullUnattendedProgramFilesDir = "\Program Files (x86)"NoWaitAfterGUIMode = 1### Test 4: reformatini.exe source.ini.; Generated by ERROR[Data]AutomaticUpdates = "No"Autopartition = 0MsDosInitiated = 0UnattendedInstall = "2 + 4"[Unattended]UnattendMode = FullUnattendedProgramFilesDir = "\Program Files (x86)"NoWaitAfterGUIMode = 1### Test 5: reformatini.exe source.ini destination.ini.### Test 6: reformatini.exe source.ini > destination_echoed.ini.Press any key to continue . . .

    Test 5 and 6 output to file so you may see no output in the CMD window.

     

    Output from one of the destination files. Winmerge shows that both output files are identical.

    ; Generated by ERROR[Data]AutomaticUpdates = "No"Autopartition = 0MsDosInitiated = 0UnattendedInstall = "2 + 4"[Unattended]UnattendMode = FullUnattendedProgramFilesDir = "\Program Files (x86)"NoWaitAfterGUIMode = 1

    The tests seem OK to me. I have not tested a UTF-8, UTF-16... file though it should be good.

     

    Use the executable like any one of these commands:

     

    Syntax: reformatini.exe /? | -? | -h
    Syntax: reformatini.exe source.ini [destination.ini]
    Syntax: type source.ini | reformatini.exe

     

    | is alternate except in the last command. [ ] is optional.

     

     

    Let me know how it works for you.

     

    Edit: Updated about the | not being an alternate in the last command which may have been confusing otherwise.

  15. Welcome Vespian,

    Here is something that may help. It is just the part that you requested help with.

    @echo offsetlocal enabledelayedexpansionrem Ensure regData is undefined now so it can be tested later if it has been defined.set "regData="rem Token 2 is %%A, which is expected to be REG_SZ. Used only to get to token *, which is %%B, which is all of the data value.for /f "tokens=2*" %%A in ( 'reg query "HKLM\SOFTWARE\Network Associates\ePolicy Orchestrator\Agent" /v ePOServerList') do set "regData=%%~B"rem If regData is not defined, then seems no good continuing?if not defined regData goto :stoprem Show the value of regData. Use delayed expansion as you can expect pipe characters in the string.echo regData=!regData!rem If substitution fails, then equality is true.if "!regData:CMCSU-EPO-01.cict.local=!" == "!regData!" goto :stoprem You only want to install framepkg.exe once. Need a flag variable to decide this i.e. if not %installed% ..."framepkg.exe" /Install=Agent /Silent:stoppauseendlocalgoto :eof

    As mentioned in a comment, you only want to install framepkg.exe once so create a variable to use as a flag. Once the script installs framepkg.exe, then set the flag variable to a value i.e. 1. The you can test the variable later for value of 1 and not install if true. Use an initial value i.e. 0.

     

  16. The default menu in Windows 7 is basically a treeview control, at least the "All Programs" part of it is a treeview control. The left pane of Regedit has a treeview control. You would navigate the Regedit treeview control like you would navigate the Windows 7 Startmenu. Many other programs, such as Explorer uses treeview controls.

     

    Here is step by step instruction set for navigating the Windows 7 Startmenu to start Calculator. Number of key strokes may vary depending on your menu items. The order of key strokes is from top to bottom.

    Keys        Destination----        -----------{Windows}   Search edit control{Up}        All Programs node{Left}      Opened All Programs node{Down 2}    Accessories node{Left}      Opened Accessories node{Down}      Calculator shortcut node{Return}    Opened Calculator shortcut nodeNote----{Down}, {Up}, {Left} and {Right} are the arrow keys on your keyboard.{Down 2} = {Down} + {Down}
    These keys are consistent with using a treeview control created by the Win32 API (Application Programming Interface) and maybe some other APIs. The classic menu uses similar keys to navigate IIRC on Windows 95 and later version of Windows.
  17. vinifera,

    I am at a disadvantage with the alternative workings of a OSX desktop as I have not used an Apple based desktop since their initial introduction around 1980. On Windows, I usually set stuff stored on the desktop as hidden and show it when I want access to it. With Gnome 3 on a Linux distro, icons and stuff on the desktop is not allowed unless a configuration is modified and so I store no stuff on the desktop on Gnome 3.

    What I see you wanting is like a task based system when the desktop switches. Without my knowing of what OSX does about this, I see menus (possibly either as dynamic with desktop switching or the usual static type) as a resource for tasks. Though, what I see of both Windows (8 + 2) 10 and with Gnome 3 is that menus are rather lacking in functionality. The Gnome 3 developers looked into task based (virtual) desktops and seem to have given up on it. I have little confidence in Microsofts wannabe Desktop-Phone-XBox-Tablet-Netbook All-In-One OS is going to achieve any better.

     

    If I get a chance, I will have a look at an OSX desktop. I believe KDE >v4.0 on a Linux distro has a task based system built in and may need to look into how they implement it into (virtual) desktop switching.

  18. Updated my last post with an edit.

    ...

    Edit: Added ENABLEDELAYEDEXPANSION to expand errorlevel variables used between () rounded braces. This affects only error message output displaying the value of the variable of errorlevel though is still misleading if error output is always seen as an unset value or as 0. Note, Reference of errorlevel variable is %errorlevel% changed to !errorlevel!.

     

    As per usual for testing, add the word PAUSE on a separate line immediately before or after the use of ENDLOCAL to pause the script and see any error output if issues occur.

    One of the rare times that I chose to omit ENABLEDELAYEDEXPANSION when it was actually needed. Hey, perhaps I deserve this threads award for a simple yet stupid mistake.

  19. make REAL virtual desktops, not just revamped crap from NT 4 days under new name

    You have me curious. What complies as a REAL virtual desktop? I can think of a few things possible with virtualization though I would like to know your actual view on this subject.

  20. Along with jaclaz idea, a symlink could be created as well. May as well create a symlink for static path handling and use the last.ini for reference to the last date. The use of a static path can help with WAIK tools or similar and less maintenance of suggested code in other scripts that also access the image file.

     

    This code is not tested so let me know if issues exist so I can fix it. I expect it to work though I have been wrong before.

    @ECHO OFFSETLOCAL ENABLEDELAYEDEXPANSIONrem # Set the date to a variable named Today.SET Today=%date:~10,4%-%date:~4,2%-%date:~7,2%rem # Make a folder for Today.IF NOT EXIST i:\lenovo\base\blank\%Today%\ MD i:\lenovo\base\blank\%Today%rem # Capture the image to Todays folder.imagex /compress fast /capture D: i:\lenovo\base\blank\%Today%\image.wim "Laptop Base Image"rem # Write Todays date to last.ini and symlink the image if no error detected from imagex.IF ERRORLEVEL 1 (	rem # Output the detection of an imagex error.	>&2 ECHO Error !errorlevel! set by imagex.	>&2 IF EXIST i:\lenovo\base\blank\%Today%\image.wim ECHO Image does exist in Todays directory.) ELSE (	rem # Write the last date to last.ini.	(ECHO TheLast=%Today%)>i:\lenovo\base\blank\last.ini		rem # Remove the last symlink as mklink does not overwrite.	IF EXIST i:\lenovo\base\blank\image.wim DEL i:\lenovo\base\blank\image.wim		rem # Create symlink in the blank directory to Todays image.	mklink i:\lenovo\base\blank\image.wim i:\lenovo\base\blank\%Today%\image.wim	IF ERRORLEVEL 1 >&2 ECHO Error !errorlevel! set by mklink.)ENDLOCALGOTO :EOF

    Edit: Added ENABLEDELAYEDEXPANSION to expand errorlevel variables used between () rounded braces. This affects only error message output displaying the value of the variable of errorlevel though is still misleading if error output is always seen as an unset value or as 0. Note, Reference of errorlevel variable is %errorlevel% changed to !errorlevel!.

     

    As per usual for testing, add the word PAUSE on a separate line immediately before or after the use of ENDLOCAL to pause the script and see any error output if issues occur.

  21. FileVerifier++ has many hash algos which you could try. It has a CLI named fvc.exe.
     

    If I add your checksum output into a file named hash.txt and use this code:

    @echo offsetlocal enabledelayedexpansionfor /f "tokens=1-2 delims= " %%A in (hash.txt) do (	set "hash=%%A"	set "file=%%B"		rem Remove ?SHA1* which is 6 characters trimmed from the 2nd token.	set "file=!file:~6!"		if not "!hash:~1!" == ";" (		echo !hash! !file!	))endlocalgoto :eof

    I get an output of:

    778e7656fa79a073adbee3be578b50e8c58e7f5a files.7z.001860993761f8420c84430d945b4f31379f49bc2f7 files.7z.002ef996f72db0131b9983fb0f18f823a81418b34cc files.7z.003

    Seems clean AFAIK.

  22. Hello radix,
     
    IMO, best place to look at first is the command For /?. Look for the usebackq option.
     
    Quote from For /?:

    usebackq        - specifies that the new semantics are in force,
                      where a back quoted string is executed as a
                      command and a single quoted string is a
                      literal string command and allows the use of
                      double quotes to quote file names in
                      file-set.

     
    To change behaviour of how quoting works, use the backquotes option.
     
    Using the backquotes option allows you to use double quotes to brace the variable that stores the path that may also have some whitespace.

    FOR /F "usebackq delims=" %%l IN ("%%f") DO (
×
×
  • Create New...