
Calling system command from batch
Moderator: DosItHelp
-
- Posts: 2
- Joined: 16 Jun 2012 16:32
Calling system command from batch
I am making an installation batch program where it copies the files into the correct folders and then runs a registry file to give them the correct icon. Although I need to find a way to call, I believe SHCNE_ASSOCCHANGED from SHChangeNotify API so that it can update the icon. Help much appreciated 

Re: Calling system command from batch
It's true that you could update file type icons using SHChangeNotify API but unfortunately you can't call it directly from a batch file. You need a programming language to compile a 3rd party application where that API is called.
Not sure if the following would help. If you've got installed the .NET framework then you should have csc.exe on board. It's a C# compiler.
Try that ugly combination of batch and C# code to compile your own refresh tool.
refresh.bat (all in one file):
Regards
aGerman
Not sure if the following would help. If you've got installed the .NET framework then you should have csc.exe on board. It's a C# compiler.
Try that ugly combination of batch and C# code to compile your own refresh tool.
refresh.bat (all in one file):
Code: Select all
/* &@cls
:: Batch code:
@echo off
for /f "delims=" %%i in ('dir /a-d /b /s "%SystemRoot%\Microsoft.NET\Framework\csc.exe" 2^>nul') do set "csc=%%i"
if not defined csc (
echo "csc.exe" not found, compiling impossible.
pause>nul
goto :eof
)
call "%csc%" /nologo /target:exe /out:"%~dpn0.exe" "%~f0"
:: call "%~dpn0.exe"
:: del "%~dpn0.exe"
pause
goto :eof
:: C# code:
*/
using System;
using System.Runtime.InteropServices;
class Program
{
[DllImport("shell32.dll", CharSet = CharSet.Auto)]
private static extern void SHChangeNotify(long wEventId, uint uFlags, IntPtr dwItem1, IntPtr dwItem2);
private const long SHCNE_ASSOCCHANGED = 0x08000000;
private const uint SHCNF_IDLIST = 0x0000;
static void Main(string[] args)
{
SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, IntPtr.Zero, IntPtr.Zero);
}
}
Regards
aGerman
Re: Calling system command from batch
Why not use something like NSIS instead.
http://nsis.sourceforge.net/Main_Page
http://nsis.sourceforge.net/Main_Page
-
- Posts: 2
- Joined: 16 Jun 2012 16:32
Re: Calling system command from batch
Thanks, I will try both methods and see which one is easier/more fitting 
