Batch file make a website to homepage in all browsers - web

I've been looking for how to do this but failed.
I want a batch file to change the homepage for all my browsers (IE, Firefox and Chrome) at the same time may be?
I hope I can help, thanks!

Create a Batch file with
REG ADD "HKCU\SOFTWARE\MICROSOFT\INTERNET EXPLORER\MAIN" /V "START PAGE" /D "https://google.com/" /F
Double click it will make homepage in Internet explorer

In Internet Explorer:
you can do that like below:
REG ADD "HKCU\Software\Microsoft\Internet Explorer\Main" /V "Start Page" /D "http://www.google.com/" /F
In Firefox:
FF uses a JavaScript (prefs.js in your FireFox User Profile) and not a Registry entry.
What you will need to do is programmatically edit the prefs.js file in the user profile for Firefox found in the directory C:\Users\ [USERNAME]\AppData\Roaming\Mozilla\Firefox\Profiles\ [Subfolder]
You will need to add or edit the line that looks like: user_pref("browser.startup.homepage", "www.google.com"); as:
#Echo off
taskkill /im firefox.exe* /f
cd /D "%APPDATA%\Mozilla\Firefox\Profiles"
cd *.default
set ffile=%cd%
echo user_pref("browser.startup.homepage", "https://www.google.com");>>"%ffile%\prefs.js"
set ffile=
cd %windir%
Another option using JavaScript is:
You can change the Firefox homepage by setting the preference "browser.startup.homepage"
The easiest way to do this in an add-on via JavaScript is:
Components.utils.import("resource://gre/modules/Services.jsm");
Services.prefs.setCharPref("browser.startup.homepage", "http://www.google.com");
In Google chrome:
chrome settings are in %USERPROFILE%\Local Settings\Application Data\Google\Chrome\User Data.ChromotingConfig.json and are a little bit encrypted.
but you can do a workaround like by just pasting following javascript into the "Home Page" pref field (under your Chrome options) and it works as expected when clicking the "Home" button.
javascript:(function(){ window.location.href='http://www.google.com/';})();

Related

npm.cmd opens in notepad instead of being executed (ASP.NET Web API + Angular)

I have a problem very similar to this one, but instead of a command line application, I have a ASP.NET Web API project with an Angular project inside of it, created using a dotnet template 'angular' (dotnet new angular --name something. .NET 6.0.401).
When I run the application with dotnet run and open localhost:5097 I get a blank page with a message "Launching the SPA proxy...
This page will automatically redirect to https://localhost:44415 when the SPA proxy is ready." The console constantly prints info: Microsoft.AspNetCore.SpaProxy.SpaProxyMiddleware[0]
SPA proxy is not ready. Returning temporary landing page.
over and over again.
When I enter localhost:44415 I get an error in the console that says
fail: Microsoft.AspNetCore.SpaProxy.SpaProxyLaunchManager[0]
Couldn't start the SPA development server with command 'npm start'.
and a notepad window is opened with content
:: Created by npm, please don't edit manually.
#ECHO OFF
SETLOCAL
SET "NODE_EXE=%~dp0\node.exe"
IF NOT EXIST "%NODE_EXE%" (
SET "NODE_EXE=node"
)
SET "NPM_CLI_JS=%~dp0\node_modules\npm\bin\npm-cli.js"
FOR /F "delims=" %%F IN ('CALL "%NODE_EXE%" "%NPM_CLI_JS%" prefix -g') DO (
SET "NPM_PREFIX_NPM_CLI_JS=%%F\node_modules\npm\bin\npm-cli.js"
)
IF EXIST "%NPM_PREFIX_NPM_CLI_JS%" (
SET "NPM_CLI_JS=%NPM_PREFIX_NPM_CLI_JS%"
)
"%NODE_EXE%" "%NPM_CLI_JS%" %*
which is understandably the same as the npm.cmd's content in my node.js directory. The window name is also "npm.cmd".
As mentioned in the thread I attached previously, I removed a file association for .js in windows settings, but it hasn't changed anything. The last comment there says something about changing the contents of "lb-discover.cmd" file. I don't think an ASP.NET + Angular project has an analogical file to it.
I suspect it might have something to do with file association in windows, but I can't change it for .cmd files.
Thanks in advance.
As suggested by #Yitz - this thing worked
Open your .csproj file for editing, find the following property:
<SpaProxyLaunchCommand>npm start</SpaProxyLaunchCommand>
and change it as follows:
<SpaProxyLaunchCommand>cmd.exe /c npm start</SpaProxyLaunchCommand>
This should work around possible issues with file association for .cmd

How to sign in windows installer using electron builder

I am configuring package.json for windows. The packager is working fine. But, I also want to sign my windows installer file and unable to do.
I have gone through this tutorial WindowsConfiguration and got this line:
sign String | (configuration: CustomWindowsSignTaskConfiguration) =>
Promise - The custom function (or path to file or module id) to sign
Windows executable.
The problem is, I am not getting how to create JS file for windows installer signing and what parameters I have to use for its configurations. Thanks for your time.
With electron-builder, the only thing you need to sign your Windows application is to set this two Environment Variables CSC_LINK and CSC_KEY_PASSWORD as explained here : https://www.electron.build/code-signing.
-- alternative --
You can do the same by setting this in your package.json like this (but not recommended):
"build": {
...
"win": {
...
"certificateFile": "path to your cert",
"certificatePassword": "the password of your cert"
}
}
Hope this helps.
You can create your own signtool to sign what you need.
Firstly, you need signtool.exe from Microsoft: https://learn.microsoft.com/en-us/dotnet/framework/tools/signtool-exe
Then call child_process.exec to sign your file, for example:
exec(`call "${PATH_TO_SIGNTOOL_EXE}" sign /f "${KEY_SHA256}" /p ${PASS_KEY_SHA256} /fd sha256 /tr "http://sha256timestamp.ws.symantec.com/sha256/timestamp" /td sha256 /as /v "${FILE_TO_SIGN}"`)

signtool fail with inno setup : 0x80070003 - "Store IsDiskFile() failed"

I'm getting a weird error whiles signing my software. I'm using inno setup 4.5.2.
Running Sign Tool command: signtool.exe sign /a /f cert.pfx /v /t "http://timestamp.verisign.com/scripts/timstamp.dll" /p pwd /d "Setup Label" "out\uninst.e32.tmp"
SignTool Error: An unexpected internal error has occurred.
Error information: "Error: Store IsDiskFile() failed." (-2147024893/0x80070003)
Error in W:\path\installer.iss: Sign Tool failed with exit code 0x1.
Compile aborted.
Command line seems pretty ok, it even work outside the inno setup compile. While setting the SignedUninstaller=no get me farther, it still make this error while trying to sign the output setup file.
Now i've looked pretty much everywhere for that error code (0x80070003) and/or the message "Store IsDiskFile() failed". I have also tried with multiple version of signtool.
I figured out the problem, the path to the certificate must be relative to the installer output path, not the current working folder. In this case, it would be "..\cert.pfx".
I had the same problem. My problem was I have used " in the signTool command, while I needed to use $q instead. Surprisingly it was successfully signed the executable but it failed to sign the result setup.exe file.
In my case I had the wrong Path for the certificate file. A message like "pfx not found" would much be better than just "IsDiskFile() failed."....
My problem was having the .pfx file on a network drive (G:). Moving it to a lokal drive (C:) solved the problem.

How to silently/automatically install Desktop Experience in Azure?

I need to install Desktop Experience in Azure Worker Role. Installing DE via the command line can be done with:
c:\servermanagercmd -install Desktop-Experience
And then a reboot is required.
How can I best make this work in Azure Worker Role?
UPDATE:
1) Make sure to use OS Family 2 and SDK >=1.3
2) Use elevated startup task to call included batchfile with this command:
3) servermanagercmd -install Desktop-Experience -restart -resultPath results.xml
I have tried
a) to put that commandline in a batch/.cmd file and run it via an elevated startup task. Result: The worker role keeps Aborting and restarts in a neverending loop.
b) I have tried to create a new Process() in OnStart(), under elevated runtime, something like this:
ServiceDefinition.csdef:
Runtime executionContext="elevated"
WorkerRole.cs:
public override bool OnStart()
{
if (!System.IO.File.Exists("Startup\\InstallationFinished.txt"))
{
Process startup = new Process();
startup.StartInfo.FileName = "Startup\\InstallDesktopExperience.cmd";
startup.StartInfo.CreateNoWindow = true;
startup.EnableRaisingEvents = true;
startup.Start();
startup.WaitForExit();
System.IO.File.WriteAllText("Startup\\InstallationFinished.txt",
"Installation is complete.");
startup.StartInfo.FileName = "Startup\\Reboot.cmd";
startup.Start();
}
base.OnStart();
}
InstallDesktopExperience.cmd:
servermanagercmd -install Desktop-Experience
Reboot.cmd:
shutdown /r
The result is that the Event Viewer in the Azure Worker Role shows an exception from TrustedInstaller (0xc0000005). After this error is shown in the event log, DE cannot be installed manually by opening a command line window and typing the command either. I get the error:
Error: Installation of [Desktop Experience] failed. Attempt to install Desktop Experience failed with error code 0x80080005. Server execution failed (Exception from HRESULT: 0x80080005 (CO_E_SERVER_EXEC_FAILURE))
(but it works by doing it manually in a command line window if I haven't run the code in OnStart)
I'm lost. Thanks in advance for any and all suggestions.
You should reference this guide from Wage Wegner. It deals with Expression Encoder, but the prereq of Desktop Experience is exactly the same:
http://www.wadewegner.com/2011/01/using-expression-encoder-4-in-a-windows-azure-worker-role/
Snippet from the same, but you should take the time to read his explanation on some of these concepts
REM : Install the Desktop Experience
ServerManagerCMD.exe -install Desktop-Experience -restart -resultPath results.xml
REM : Make a folder for the AppData
md "%~dp0appdata"
REM : Change the location of the Local AppData
reg add "hku\.default\software\microsoft\windows\currentversion\explorer\user shell folders" /v "Local AppData" /t REG_EXPAND_SZ /d "%~dp0appdata" /f
REM : Install Encoder
"%~dp0\webpicmd\WebPICmdLine.exe" /accepteula /Products: ExpressionEncoder4 /log:encoder.txt
REM : Change the location of the Local AppData back to default
reg add "hku\.default\software\microsoft\windows\currentversion\explorer\user shell folders" /v "Local AppData" /t REG_EXPAND_SZ /d %%USERPROFILE%%\AppData\Local /f
REM : Exit gracefully
exit /b 0

How to configure CGI on IIS 7?

I did this
http://reboltutorial.com/images/rebol-iis.png
as explained here but it was for IIS 6
http://rebolforum.com/index.cgi?f=printtopic&topicnumber=39&archiveflag=new
I also activated 32 bits for application pool as explained here
http://blogs.iis.net/wadeh/archive/2009/04/13/running-perl-on-iis-7.aspx
But when browsing to the test script it doesn't work, seems to take forever showing nothing, then in the end shows this message error:
502 - Web server received an invalid response while acting as a gateway or proxy server.
There is a problem with the page you are looking for, and it cannot be displayed. When the Web server (while acting as a gateway or proxy) contacted the upstream content server, it received an invalid response from the content server.
I used a dedicated server on windows 2008
Source code of the test script:
REBOL [Title: "Cgi Test in Rebol"]
print "HTTP/1.0 200 OK^/Content-type:text/html^/^/";
print []
print ["Date/time is:" now]
print []
Should I ask on serverfault rather as nobody seems to know here ?
Finally I got my answer, here are the steps:
Open Server Manager from Administrative Tools.
Add role "Web Server (IIS)"
Try http://localhost/ from your browser. You should see the IIS7 Welcome Page.
Copy core.exe to c:\ (or somewhere else), right click on core.exe and open Properties window, give Read & Execute access to IUSR_xxxx under Security tab. (If you've any problem, try to give Read & Execute for Everyone)
Open "Internet Information Services (IIS) Manager" from Administrator Tools.
Click on Default Web Sites, double click on Handler Mappings, click on Add Module Mapping from the right panel and type the followings:
Request Path: *.r
Module: c:\core.exe -cs %s %s
Name: Rebol
Select Yes when Add Script Map dialog box appears. It will add the c:\core.exe -cs "%s %s" as allowed under ISAPI and CGI Restrictions list.
Create a test.r file under wwwroot folder. My test.r file contains following script:
R E B O L [Title: "Server Time"]
print "content-type: text/html^/"
print [<HTML><BODY>]
print ["Date/time is:" now]
print [</pre></BODY></HTML>]
And type http://localhost/test.r on your browser.
If everything goes well then it should work.
If you are trying with View.exe then you may need to put --noinstall to command line, otherwise when View start with IUSR_xxx user account it will open desktop & installation window and it stays background (you can see it from Task Manager).
c:\view.exe -csi %s %s
You may also need to put double quotes around %s if your script is in a path with spaces. Use the following form:
c:\core.exe -cs "%s %s"
Instead of this:
c:\core.exe "-cs %s %s" (<-- this won't work!)
I hope this will help.
UPDATE: I've faced a problem on IIS6 (Windows 2003 Server), it gives 404 when I configure it as follow (it works on IIS7 as told above):
c:\core.exe -cs "%s %s"
But it runs as:
c:\core.exe" -cs "%s" %s
Here is the link for Perl installation.
http://www.howtogeek.com/50500/how-to-install-perl-on-iis-6-for-windows-server-2003/

Resources