How to Launch a WSH VBScript as Administrator in Windows 7 and Vista
The example below launches a VB script as administrator on Windows 7 and Vista regardless if the context menu contains the "Run as administrator" option. Registry tweaks exist to add the run as administrator option to the context menu for .vbs files but this creates complications if the script is distributed to other people.
When the script below is executed it checks to see if it was passed a command line argument named "elevated". If it is not found the script recursively calls itself passing the elevated command line argument and requests to be run as administrator. The user is prompted to confirm the action and the restricted script exits leaving the escalated administrator script running. When the user grants permission the elevated argument is found and the script changes back from the %System32% working directory to the script where the script is located.
If WScript.Arguments.Named.Exists("elevated") = False Then
'Launch the script again as administrator
CreateObject("Shell.Application").ShellExecute "wscript.exe", """" & WScript.ScriptFullName & """ /elevated", "", "runas", 1
WScript.Quit
Else
'Change the working directory from the system32 folder back to the script's folder.
Set oShell = CreateObject("WScript.Shell")
oShell.CurrentDirectory = CreateObject("Scripting.FileSystemObject").GetParentFolderName(WScript.ScriptFullName)
MsgBox "Now running with elevated permissions"
End If
Give Google An Answer To Find the Question!?
This is a anecdote of how Google gave the question to the answer I already had.
Normally, people input questions and keywords into Google to find an answer. In my case the answer was known. Use caspol.exe with the -pub -file arguments to trust all the assemblies signed with my certificate. The MSDN caspol.exe documentation was helpful but the exact syntax for implementing the command was a little fuzzy.
When in doubt Google it. Behold, the question to my answer stated in a question:
"What does this statement do? caspol -machine -addgroup All_Code -pub -file MyApp.exe FullTrust"
Thanks to Matthew Podwysocki his question fit my answer and provided the syntax needed to complete my work with caspol.
Tips to upgrade and maintain X-Cart PHP shopping cart
During a recent shopping cart upgrade these three tips came to mind. Mostly when I failed to follow my own advice. The tips are in regards to manually patching files that have been customized.
- Comment, comment, comment. If you make a change to a PHP file or template that was supplied by the vendor make a comment. Know what line the change started and where the change ends. When manually patching the file the comments will keep you from having to guess if a change is a patch from the vendor or a customization you made.
- When making a customization, comment out the original code block using block comments (not line comments) and make your changes to a copy of the original code block. Eventually when the original code gets patched or updated by the vendor you will still have a reference to the original code and a utility like WinMerge will be able to help match up the changes to the original code.
- For files that need manual patching use a utility such as WinMerge to find and resolve conflicts. If you make ample comments and left original code blocks in place WinMerge will better be able to help you get the file patches and your customizations back in place.
Good luck on patching your custom cart!