L
Lucvdv
For the TIPS section:
Some time ago, there was a discussion about installing SP1 and SP2 side by
side and toggling between them for different projects.
( Message-ID: <#[email protected]> )
I just created something that may be useful to those who installed it that
way.
I've always had shortcuts to TD, component designer and the component
database manager on my quick launch bar. Today I added a fourth icon that
displays which service pack version is current, and flips to the other when
clicked.
Behind it is a small VB6 app, of which you find the source below.
The shortcut icon is either the "R1" or "R2" icon from moricons.dll and
must be preset to one of those when the shortcut is created.
Moricons.dll is normally present in the system32 folder by default.
The icon indexes in the file are 82 and 83 on XP Pro, on Win2000 you may
have to change the VB source a little if they happen to be different.
The actual switching from one SP to the other is done by two .cmd files (I
already had those and didn't modify them, just call them from the VB app).
The .cmd files follow first.
"|" indicates start of a line, if your newsreader breaks a line in
mid-command it won't be there so you know it's a continuation of the
previous line.
This is the file that switches to SP1, for the other one just replace SP1
by SP2 in the paths. You'll probably have to adjust them to where you
installed the repositories on your system anyhow.
On my system, the SP1 database and repositories are installed in D:\Windows
Embedded\XPeSP1\ and SP2 in D:\Windows Embedded\XPeSP2\.
"osql" is osql.exe in the SQL Server binn folder, add it to your path if
necessary (I think it's there by default, but I'm not certain).
| osql -E -Q "sp_detach_db 'MantisSQLDB'"
| net share Repositories /DELETE
| net share Repositories="D:\Windows Embedded Data\XPeSP1\Repositories"
| osql -E -Q "sp_attach_db 'MantisSQLDB', 'D:\Windows Embedded Data\XPeSP1\MantisSQLDB_Data.mdf', 'D:\Windows Embedded Data\XPeSP1\MantisSQLDB_Log.ldf'"
| pause
Now the VB app.
Create a new standard application, remove Form1 from the workspace and add
a standard module instead, make sure the entry point in project properties
is "Sub Main", add "Microsoft Shell Controls and Automation" to the project
references, and paste the code below into the module.
You'll have to adjust the line with the path to the Quick Launch toolbar
folder so it matches your system.
It alse expects two .cmd files called "XPeSP1.cmd" and "XPeSP2.cmd" in its
own folder or accessible through the path.
When the application is compiled, create a shortcut called "ToggleSP" to it
in the quick launch toolbar (make sure it has no extension in explorer: the
filename in a DIR command in a cmd window should be "ToggleSP.lnk").
Sub Main()
Dim sh As Shell32.Shell
Dim sc As Shell32.ShellLinkObject
Dim fo As Folder
Dim fi As FolderItem
Dim IconIndex As Long, IconPath As String
Set sh = CreateObject("Shell.Application")
' Next line broken by newsreader
Set fo = sh.NameSpace("C:\Documents and Settings\lucvdv\Application
Data\Microsoft\Internet Explorer\Quick Launch")
' The lines above are one statement
For Each fi In fo.Items
If fi.Name = "ToggleSP" And fi.IsLink Then Exit For
Next
If Not fi Is Nothing Then
Set sc = fi.GetLink
IconIndex = sc.GetIconLocation(IconPath)
Select Case IconIndex
Case 82
sc.SetIconLocation IconPath, 83
sc.Save
Shell "XPeSP2.cmd", vbNormalFocus
Case 83
sc.SetIconLocation IconPath, 82
sc.Save
Shell "XPeSP1.cmd", vbNormalFocus
End Select
End If
End Sub
BTW: I tried turning it into a .vbs script instead of a compiled
application, but it seems that sc.GetIconLocation doesn't work in a script
(it gives a Type Mismatch error).
Some time ago, there was a discussion about installing SP1 and SP2 side by
side and toggling between them for different projects.
( Message-ID: <#[email protected]> )
I just created something that may be useful to those who installed it that
way.
I've always had shortcuts to TD, component designer and the component
database manager on my quick launch bar. Today I added a fourth icon that
displays which service pack version is current, and flips to the other when
clicked.
Behind it is a small VB6 app, of which you find the source below.
The shortcut icon is either the "R1" or "R2" icon from moricons.dll and
must be preset to one of those when the shortcut is created.
Moricons.dll is normally present in the system32 folder by default.
The icon indexes in the file are 82 and 83 on XP Pro, on Win2000 you may
have to change the VB source a little if they happen to be different.
The actual switching from one SP to the other is done by two .cmd files (I
already had those and didn't modify them, just call them from the VB app).
The .cmd files follow first.
"|" indicates start of a line, if your newsreader breaks a line in
mid-command it won't be there so you know it's a continuation of the
previous line.
This is the file that switches to SP1, for the other one just replace SP1
by SP2 in the paths. You'll probably have to adjust them to where you
installed the repositories on your system anyhow.
On my system, the SP1 database and repositories are installed in D:\Windows
Embedded\XPeSP1\ and SP2 in D:\Windows Embedded\XPeSP2\.
"osql" is osql.exe in the SQL Server binn folder, add it to your path if
necessary (I think it's there by default, but I'm not certain).
| osql -E -Q "sp_detach_db 'MantisSQLDB'"
| net share Repositories /DELETE
| net share Repositories="D:\Windows Embedded Data\XPeSP1\Repositories"
| osql -E -Q "sp_attach_db 'MantisSQLDB', 'D:\Windows Embedded Data\XPeSP1\MantisSQLDB_Data.mdf', 'D:\Windows Embedded Data\XPeSP1\MantisSQLDB_Log.ldf'"
| pause
Now the VB app.
Create a new standard application, remove Form1 from the workspace and add
a standard module instead, make sure the entry point in project properties
is "Sub Main", add "Microsoft Shell Controls and Automation" to the project
references, and paste the code below into the module.
You'll have to adjust the line with the path to the Quick Launch toolbar
folder so it matches your system.
It alse expects two .cmd files called "XPeSP1.cmd" and "XPeSP2.cmd" in its
own folder or accessible through the path.
When the application is compiled, create a shortcut called "ToggleSP" to it
in the quick launch toolbar (make sure it has no extension in explorer: the
filename in a DIR command in a cmd window should be "ToggleSP.lnk").
Sub Main()
Dim sh As Shell32.Shell
Dim sc As Shell32.ShellLinkObject
Dim fo As Folder
Dim fi As FolderItem
Dim IconIndex As Long, IconPath As String
Set sh = CreateObject("Shell.Application")
' Next line broken by newsreader
Set fo = sh.NameSpace("C:\Documents and Settings\lucvdv\Application
Data\Microsoft\Internet Explorer\Quick Launch")
' The lines above are one statement
For Each fi In fo.Items
If fi.Name = "ToggleSP" And fi.IsLink Then Exit For
Next
If Not fi Is Nothing Then
Set sc = fi.GetLink
IconIndex = sc.GetIconLocation(IconPath)
Select Case IconIndex
Case 82
sc.SetIconLocation IconPath, 83
sc.Save
Shell "XPeSP2.cmd", vbNormalFocus
Case 83
sc.SetIconLocation IconPath, 82
sc.Save
Shell "XPeSP1.cmd", vbNormalFocus
End Select
End If
End Sub
BTW: I tried turning it into a .vbs script instead of a compiled
application, but it seems that sc.GetIconLocation doesn't work in a script
(it gives a Type Mismatch error).