by Shawn
9. November 2011 05:41
With the existance of UAC in the windows world, I find my self looking for easier ways to run a command as administrator (usually via command line) without needing to turn off UAC.
Here are some useful links that helped me solve this very issue
Elevation Power Toys
http://technet.microsoft.com/en-us/magazine/2008.06.elevation.aspx (note, you also need to sysinternals suite installed in "%ProgramFiles%\Sysinternal Suite"
Elevate Utility
http://code.kliu.org/misc/elevate/
Sudo for windows
http://sourceforge.net/projects/sudowin/
by Shawn
14. October 2011 06:51
Requirements:
- 7zip
- 7za.exe
- 7zip in the path
# Handle BAK and TRN files
get-childitem -recurse |
where { $_.extension -match ".(bak|trn)" -and -not (test-path ($_.fullname -replace "(bak|trn)", "7z")) } |
foreach { &7za a -t7z -mx=9 ($_.fullname -replace "bak", "7z") $_.fullname }
# Delete any BAK or TRN that has a matching 7z file
get-childitem -recurse |
where { $_.extension -match ".(bak|trn)" -and
(test-path ($_.fullname -replace "(bak|trn)", "7z")) } |
foreach { del $_.fullname }
by Shawn
14. October 2011 06:51
# Handle BAK and TRN files
get-childitem -recurse |
where { $_.extension -match ".(bak|trn)" -and -not (test-path ($_.fullname -replace "(bak|trn)", "7z")) } |
foreach { &7za a -t7z -mx=9 ($_.fullname -replace "bak", "7z") $_.fullname }
# Delete any BAK or TRN that has a matching 7z file
get-childitem -recurse |
where { $_.extension -match ".(bak|trn)" -and
(test-path ($_.fullname -replace "(bak|trn)", "7z")) } |
foreach { del $_.fullname }
by Shawn
23. December 2010 09:20
Check out http://seleniumhq.org/
Selenium is a suite of toolsto automate web app testing across many platforms.
Selenium...
by Shawn
17. November 2009 08:05
Here is a little snippet that will let you make a remote AJAX call from inside Silverlight - the only catch is that you will get a "security warning" dialog for making a crossdomain call
ScriptObjectCollection scriptCollection = HtmlPage.Document.GetElementsByTagName("head");
HtmlElement head = (HtmlElement)scriptCollection[0];
HtmlElement script = HtmlPage.Document.GetElementById("dataAccess_js");
if (script == null)
{
script = HtmlPage.Document.CreateElement("script");
script.SetAttribute("type", "text/javascript");
script.Id = "dataAccess_js";
StringBuilder sbScript = new StringBuilder();
sbScript.AppendLine("function createXMLHttpRequest() { var httprequest = false; if (window.XMLHttpRequest) { httprequest = new XMLHttpRequest(); if (httprequest.overrideMimeType) httprequest.overrideMimeType(\"text/xml\"); } else if (window.ActiveXObject) { try { httprequest = new ActiveXObject(\"Msxml2.XMLHTTP\"); } catch (e) { try { httprequest = new ActiveXObject(\"Microsoft.XMLHTTP\"); } catch (e) { } } } return httprequest; }");
sbScript.AppendLine("function retrieveContent(url) { var request = createXMLHttpRequest(); request.open(\"GET\", url, false); request.send(null); if (request.status == 200) { var text = request.responseText; return text; } else { alert(\"Error loading \" + url); } }");
script.SetProperty("text", sbScript);
head.AppendChild(script);
}
var result = HtmlPage.Window.Invoke("retrieveContent", sURL);
by Shawn
8. February 2009 16:41
Have you been looking for a way to replace all instances of notepad.exe on Windows Server 2008? If so, here is a quick and dirty batch file to help you out.
Note: I ran a "dir /s /b notepad.exe > replace_notepad.cmd" to get a list of copies of notepad.exe on the c drive, then edited the new file with what is below
@echo off
echo Create Backup copies of the original notepad.exe
copy C:\Windows\notepad.exe C:\Windows\notepad32.exe
copy C:\Windows\System32\notepad.exe C:\Windows\System32\notepad32.exe
copy C:\Windows\SysWOW64\notepad.exe C:\Windows\SysWOW64\notepad32.exe
echo Take Ownership of the files rem This could be changed to use icacls now
takeown /F C:\Windows\notepad.exe /A
takeown /F C:\Windows\System32\notepad.exe /A
takeown /F C:\Windows\SysWOW64\notepad.exe /A
takeown /F C:\Windows\winsxs\x86_microsoft-windows-notepadwin_31bf3856ad364e35_6.0.6001.18000_none_42c9ccdefb0d0dc9\notepad.exe /A
takeown /F C:\Windows\winsxs\x86_microsoft-windows-notepad_31bf3856ad364e35_6.0.6001.18000_none_6f1a8d7b6fffbb73\notepad.exe /A
takeown /F C:\Windows\winsxs\amd64_microsoft-windows-notepadwin_31bf3856ad364e35_6.1.7600.16385_none_9ebebe8614be1470\notepad.exe /A
takeown /F C:\Windows\winsxs\amd64_microsoft-windows-notepad_31bf3856ad364e35_6.1.7600.16385_none_cb0f7f2289b0c21a\notepad.exe /A
takeown /F C:\Windows\winsxs\wow64_microsoft-windows-notepad_31bf3856ad364e35_6.1.7600.16385_none_d5642974be118415\notepad.exe /A
echo Assign full rights to the administrators group
icacls c:\windows\notepad.exe /grant Administrators:F
icacls C:\Windows\System32\notepad.exe /grant Administrators:F
icacls C:\Windows\SysWOW64\notepad.exe /grant Administrators:F
icacls C:\Windows\winsxs\x86_microsoft-windows-notepadwin_31bf3856ad364e35_6.0.6001.18000_none_42c9ccdefb0d0dc9\notepad.exe /grant Administrators:F
icacls C:\Windows\winsxs\x86_microsoft-windows-notepad_31bf3856ad364e35_6.0.6001.18000_none_6f1a8d7b6fffbb73\notepad.exe /grant Administrators:F
icacls C:\Windows\winsxs\amd64_microsoft-windows-notepadwin_31bf3856ad364e35_6.1.7600.16385_none_9ebebe8614be1470\notepad.exe /grant Administrators:F
icacls C:\Windows\winsxs\amd64_microsoft-windows-notepad_31bf3856ad364e35_6.1.7600.16385_none_cb0f7f2289b0c21a\notepad.exe /grant Administrators:F
icacls C:\Windows\winsxs\wow64_microsoft-windows-notepad_31bf3856ad364e35_6.1.7600.16385_none_d5642974be118415\notepad.exe /grant Administrators:F
echo Copy new notepad.exeover the original versions
copy /y C:\notepad.exe C:\Windows\notepad.exe
copy /y C:\notepad.exe C:\Windows\System32\notepad.exe
copy /y C:\notepad.exe C:\Windows\SysWOW64\notepad.exe
copy /y C:\notepad.exe C:\Windows\winsxs\x86_microsoft-windows-notepadwin_31bf3856ad364e35_6.0.6001.18000_none_42c9ccdefb0d0dc9\notepad.exe
copy /y C:\notepad.exe C:\Windows\winsxs\x86_microsoft-windows-notepad_31bf3856ad364e35_6.0.6001.18000_none_6f1a8d7b6fffbb73\notepad.exe
copy /y C:\notepad.exe C:\Windows\winsxs\amd64_microsoft-windows-notepadwin_31bf3856ad364e35_6.1.7600.16385_none_9ebebe8614be1470\notepad.exe
copy /y C:\notepad.exe C:\Windows\winsxs\amd64_microsoft-windows-notepad_31bf3856ad364e35_6.1.7600.16385_none_cb0f7f2289b0c21a\notepad.exe
copy /y C:\notepad.exe C:\Windows\winsxs\wow64_microsoft-windows-notepad_31bf3856ad364e35_6.1.7600.16385_none_d5642974be118415\notepad.exe
notepad.exe (17.50 kb)
replace_notepad.cmd (3.64 kb)