Archive for the ‘Batch-Files’ Category
Posted by jpluimers on 2015/12/30
This is what I needed:
:: http://www.windows-commandline.com/disable-screensaver-registry-settings/
reg add "HKEY_CURRENT_USER\Control Panel\Desktop" /v ScreenSaveActive /t REG_SZ /d 0 /f
And this one to verify the current settings:
:: http://www.windows-commandline.com/disable-screensaver-registry-settings/
:: possible names
:: ScreenSaveActive
:: ScreenSaveTimeOut
:: ScreenSaverIsSecure
reg query "HKEY_CURRENT_USER\Control Panel\Desktop" | findstr /I /C:"ScreenSave"
–jeroen
via:
Posted in Batch-Files, Development, Scripting, Software Development | Leave a Comment »
Posted by jpluimers on 2015/12/29
I needed to compare the local group memberships on a few systems.
I knew there is the distinction between
- net group (which despite documentation requires /domain as it does not support local groups: you get a nice NET HELPMSG 3515 error) and
- net localgroup (which can either run locally or with /domain).
So I came up with this batch file thanks to Command Line Kung Fu:
:: http://blog.commandlinekungfu.com/2009/06/episode-43-users-groups.html
for /F "skip=4 delims=*" %%g in ('net localgroup ^| find /v "The command completed successfully"') do @net localgroup "%%g"
It can be done in PowerShell too, but is more work.
Based on that and Beyond Compare I created some diff scripts.
–jeroen
via:
Posted in Batch-Files, Development, Scripting, Software Development | 1 Comment »
Posted by jpluimers on 2015/10/29
On a system where I just added a new E: drive, it was indeed available as
wmic logicaldisk where drivetype=3 get caption,filesystem,drivetype,providername,volumename
would output:
Caption DriveType FileSystem ProviderName VolumeName
C: 3 NTFS
D: 3 NTFS
E: 3 NTFS
But it would not list as an administrative share since
net share
would give:
Share name Resource Remark
-------------------------------------------------------------------------------
IPC$ Remote IPC
ADMIN$ C:\WINDOWS Remote Admin
D$ D:\ Default share
C$ C:\ Default share
The command completed successfully.
I wonder why the E$ drive was not visible. If anyone knows a better solution than a reboot, please let me know.
This was after the reboot:
Share name Resource Remark
-------------------------------------------------------------------------------
IPC$ Remote IPC
ADMIN$ C:\WINDOWS Remote Admin
D$ D:\ Default share
E$ E:\ Default share
C$ C:\ Default share
The command completed successfully.
–jeroen
via:
Posted in Batch-Files, Development, Scripting, Software Development | Leave a Comment »
Posted by jpluimers on 2015/08/26
Thanks Jon for answering this:
for /l is your friend:
for /l %x in (1, 1, 100) do echo %x
Starts at 1, steps by one, and finishes at 100.
Use two %s if it’s in a batch file
for /l %%x in (1, 1, 100) do echo %%x
–jeroen
via: windows – Batch script loop – Stack Overflow.
Posted in Batch-Files, Development, Scripting, Software Development | Leave a Comment »
Posted by jpluimers on 2015/03/05
If you are running OpenSSL as a regular user, or cannot perform “RunAs Administrator”, and you get this error message:
unable to write 'random state'
then make sure you have set your environment variables correctly before running OpenSSL:
RANDFILE=%LOCALAPPDATA%\.rnd
A full batch file front-end for OpenSSL.exe is this one:
Read the rest of this entry »
Posted in Batch-Files, Development, OpenSSL, Power User, Scripting, Security, Software Development, Windows | Leave a Comment »
Posted by jpluimers on 2015/01/22
Wow: I feel like having lived under a stone for 8 years, as RosettaCode has been alive since it was founded in 2007 by Mike Mol.
The idea is that you solve a task and learn from that, or learn by seeing how others have solved tasks or draft tasks.
So in a sense it is similar to the Rosetta stone: it has different languages phrasing the same tasks.
There are already a whole bunch of languages on RosettaCode (of which a few are in the categories below), and you can even suggest or add your own languages.
When you want to solve tasks, be sure to look at the list unimplemented tasks by language that leads to automatic reports by language (for instance two of the languages I use most often: C# and Delphi).
I’m sure there are lots of programming chrestomathy sites, even beyond the ones, and it feels very similar to programming kata sites.
–jeroen
Posted in .NET, APL, Awk, bash, Batch-Files, C, C#, C++, COBOL, CommandLine, Delphi, Development, Fortran, FreePascal, Java, JavaScript/ECMAScript, Lazarus, Object Pascal, Office VBA, Pascal, Perl, PHP, PowerShell, PowerShell, Prism, Scripting, sed script, Sh Shell, Software Development, Turbo Prolog, VB.NET, VBS, VBScript, Visual Studio and tools, Web Development | Leave a Comment »
Posted by jpluimers on 2014/11/06
Two interesting links today about Delphi and Batch files.
–jeroen
PS: If you want to see some serious Batch file and PowerShell related scripts, then read through the Build Automation part of my session materials I posted to ITDevCon and EKON session materials on Delphi Unit Testing + Build Automation and Continuous Integration on-line.
More details are in the batch files here:
and PowerShell scripts here:
Posted in Batch-Files, Delphi, Delphi 2005, Delphi 2006, Delphi 2007, Delphi 2009, Delphi 2010, Delphi 7, Delphi XE, Delphi XE2, Delphi XE3, Delphi XE4, Delphi XE5, Delphi XE6, Delphi XE7, Development, QC, Scripting, Software Development | 7 Comments »
Posted by jpluimers on 2014/10/08
I never realized you could overwrite the CD pseudo environment variable. If you do, the automatic value of the pseudo variable will not be udpated any more:
You have at some point set the CD variable explicitly. If you do this it will no longer automatically reflect the current working directory. To undo this, set it to empty:
set CD=
Thanks Jonathan and … for explaining this in both your answers.
Thanks to another answer by Endoro I now also know of the %=C:% pseudo variable (you have one per drive letter) that indicate the current directory per drive letter.
–jeroen
via: batch file – When is the CD environment variable updated? – Stack Overflow.
Posted in Batch-Files, Development, Power User, Scripting, Software Development, Windows, Windows 7, Windows 8, Windows Server 2000, Windows Server 2003, Windows Server 2003 R2, Windows Server 2008, Windows Server 2008 R2, Windows Vista, Windows XP | 2 Comments »
Posted by jpluimers on 2014/10/06
I just found this [Wayback] great answer (which by now regrettably is deleted; the previous Wayback link still has it) by [Wayback] Јοеу a.k.a. Johannes Rössel on [Wayback] What encoding/code page is cmd.exe using.
The whole answer is worth reading, so I won’t quote only some bits.
Edit 20210609: the answer now has been replaced by an even more detailed answer [Wayback] by [Wayback] andrewdotn. Also recommended reading. The summary of the new answer is this:
The moral of the story?
type can print UTF-16LE files with a BOM regardless of your current codepage
- Win32 programs can be programmed to output Unicode to the console, using
WriteConsoleW.
- Other programs which set the codepage and adjust their output encoding accordingly can print Unicode on the console regardless of what the codepage was when the program started
- For everything else you will have to mess around with
chcp, and will probably still get weird output.
–jeroen
via: windows – What encoding/code page is cmd.exe using – Stack Overflow.
Posted in Batch-Files, Development, Encoding, Power User, Scripting, Software Development, Windows, Windows 7, Windows 8, Windows Server 2000, Windows Server 2003, Windows Server 2003 R2, Windows Server 2008, Windows Server 2008 R2, Windows Vista, Windows XP | Leave a Comment »