auto-start app minimized from Windows 8 registry - windows

I need to be able to start a command line app minimized, and have it auto-start on Windows 8.1 at user login.
The following command works well at the Windows 8.1 command line:
start /min /D c:\"program files (x86)"\mycompanyname myappname.exe
However it fails to work in the registry at HKCU\software\Microsoft\Windows\CurrentVersion\Run.
Help please

Option #1:
cmd.exe /c "start /min /D c:\"program files (x86)"\mycompanyname myappname.exe"
However you might see a black window popup and then go away.
Option #2: instead of changing registry, create a shortcut in %APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup In the properties of the shortcut, you can specify "Minimized" option.
Option #3: write a startMinimized.vbs script like this one (untested):
set objShell = CreateObject( "WScript.Shell" )
objShell.Run "c:\program files (x86)\mycompanyname\myappname.exe", 2
Then in the registry
wscript.exe "c:\program files (x86)\mycompanyname\startMinimized.vbs"

Related

Use "cmd /c" but hide the console window

I have a shortcut running this command when clicked: cmd /c "full path to my batch file". When I use it, it does what it is supposed to do, but in the process the ugly console window pops up. Is there any way to make this command start a hidden or at least minimized window?
Use the command start with switch /min to start cmd in minimized window:
start /min cmd /c "full path to my batch file"
powershell "start <path of batch file> -Args \"<batch file args>\" -WindowStyle Hidden"
This can be placed in a separate batch file which, when called, will terminate immediately while your batch file executes in the background.
From ' Args ' to ' \" ' can be excluded if your batch file has no arguments.
' -v runAs' can be added before the end quote to run your batch file as an administrator.
I found this solution :
Create a launch.vbs file and add
Set WshShell = CreateObject("WScript.Shell")
WshShell.Run chr(34) & "C:\Batch Files\syncfiles.bat" & Chr(34), 0
Set WshShell = Nothing
Replace "C:\Batch Files\syncfiles.bat" by your absolute or relative path file name.
Source : https://www.winhelponline.com/blog/run-bat-files-invisibly-without-displaying-command-prompt/
Source MSDN : https://msdn.microsoft.com/en-us/library/d5fk67ky(VS.85).aspx
Right-click on the shortcut icon and choose "Properties."
On the "Shortcut" tab, choose the "Run" type you desire from the dropdown menu.
The START command has a /B switch to start without creating a window. Use START /? to read all about it.
This will create a separate process (without a window), and not block parent window so it can continue your main work:
start /b cmd /c "full path to my batch file"
Use AutoHotKey file. Download and install AutoHotKey first.
suppose you have an 1.bat
you'll create a C:\2.ahk, whose content is
Run C:\1.bat,,Hide
return
and you'll create a 3.lnk, and right click it, click property, then set the Target to
"C:\Program Files\AutoHotkey\AutoHotkey.exe" C:\2.ahk
Then you'll get what you want.
This way, you can attach the 3.lnk to your taskbar or start menu, and also change its icon.
The start method can only be used in a bat, which can't be added to taskbar or changed icon.
Create a VBScript file as a shell to start it.
' Launcher.vbs
If WScript.Arguments.Count = 0 Then
WScript.Quit 1
End If
Dim WSH
Set WSH = CreateObject("WScript.Shell")
WSH.Run "cmd /c " & WScript.Arguments(0), 0, False
You may want to embed this as a Here Document in your batch file. See heredoc for Windows batch?

Windows Batch file enable quick edit for gitbash

I managed to launch gitbash from a bat file, I want also to enable quick edit mode how to do that ? thanks.
cd "C:\Program Files (x86)\Git\bin\"
mode con: cols=160 lines=78
start sh.exe --login -i
You can set a registry key to enable QuickEdit mode on all console windows launched by the current user.
reg add "HKCU\Console" /v "QuickEdit" /t REG_DWORD /d 1
You should only need to run this command once, until you switch users or reinstall your OS.

Multiple commands in UninstallString when removing an app

I'm trying to create a homemade installer that replicates the functionality of an MSI. I'm running into trouble setting the registry values for my app, specifically the UninstallString, which is supposed to run when you right-click a program and click Uninstall. This was my initial UninstallString:
regedit C:\path\to\app\uninstall.reg & rd /s /q C:\path\to\app
For some reason, the & was not interpreted correctly and it was passed as an argument to regedit, so I tried this
cmd /c "regedit C:\path\to\app\uninstall.reg & rd /s /q C:\path\to\app"
This worked fine, but it showed the console window while uninstalling. Following the advice here, I tried
start /min "..."
and
start /min cmd /c "..."
but they both resulted in an error from the Control Panel, saying the program "was already uninstalled." I also tried it the other way around:
cmd /c start /min "..."
But the black window still popped up.
Is it possible to make this work without having to show the console window?
This worked:
cmd /c start /min cmd /c "..."
Gotta love Windows.

Command to start a process in the background and run silently

I'm trying to write a command in a bat file to run an installer exe file. The important part is to start and run the installer in silent mode. To clarify, I DO NOT want the user to see the installer and click through the wizard. They should just be able to double click the bat file and walk away. I have attempted this command in my bat file:
#echo off
REM Next command runs installer in silent mode
start /d "%USERPROFILE%\Desktop" MyInstaller_7.1.51.14.exe –s –v –qn
The –s –v –qn are supposed to enable the installer to run in the background, but they are not working.
Can anyone help me improve my command in my bat file so that MyInstaller_7.1.51.14.exe is indeed running in the background, silently, with no UI or wizard of any kind visible to the user??
Please help.
You can try one of these START command options to see if it gives you the effect you want:
/B = Start application without creating a new window
/MIN = Start window minimized
Edited:
Try putting the command with its switches inside quotes:
start /d "%USERPROFILE%\Desktop" "MyInstaller_7.1.51.14.exe –s –v –qn"
Another solution you can test :
Create a file RunHide.vbs and put this line in it :
CreateObject("Wscript.Shell").Run """" & WScript.Arguments(0) & """", 0, False
and then run your batch file like this :
wscript.exe "RunHide.vbs" "Install.bat"
and your batch file will be run without any windows (and maybe your Installer to)
I finally figured it out.
Here is the correct code:
#echo off
REM Next command runs installer in silent mode
start "%USERPROFILE%\Desktop" MyInstaller_7.1.51.14.exe /s /v /qn
The change was between –s –v –qn and /s /v /qn where the former does not work, and the latter does.

Windows 7: cmd.exe: setting startup directory (in a link to cmd.exe)

I am running Windows 7 and when I run cmd.exe I want it to start up
in a directory named C:\foo\bar. I remember being able to create a
link to this executable on the desktop and right clicking somewhere
to set the startup menu of the cmd.exe command prompt by filling
out a field in a transient window, but I cannot find it. I have
found the following argument which however seems more complicated.
I want to set the startup directory for cmd.exe via a popup window.
Changing default startup directory for command prompt in Windows 7
Any ideas?
as mentioned by the other posters already:
the regular approach is to edit the shortcut's properties and fill the field labled "start in". simple as that.
however, for some reason this has no effect on UAC enabled systems if at the same time you also enable the "run as administrator" checkbox in the advanced properties of the shortcut.
a solution is to put everything in the "target" field of the shortcut:
%windir%\System32\cmd.exe /K cd /d "E:\My Folder" & sometest.bat
when running on 64bit and you want to explicitly start the 32bit flavour of the command prompt:
%windir%\SysWOW64\cmd.exe /K cd /d "E:\My Folder" & sometest.bat
for additional information on the command line parameters used above see:
cmd.exe /?
cd.exe /?
When you create a shortcut to cmd.exe, you can open the shortcut properties and find under Shortcut tab the Starts in option that will tell cmd.exe where to start, like here:
Open the properties of a shortcut to cmd and set the directory there:
Try this Shortcut Target:
C:\Windows\System32\cmd.exe cd /d %~dp0
Which will start cmd.exe in the shortcut's folder.

Resources