I want to remove the Google Chrome pinned icon on the taskbar. The uninstall does NOT remove the icon. I modified code to remove just the Google Chrome.lnk. What I want to do (knowing about VBS) is to loop through all the user folders not just the current user which is I believe defined as strCurrentUserAppData. The other desire I would like to do with this code is to use it with SCCM to do a clean install of Chrome. I installed the x64 version and need to replace it with the x86 version. When I do the uninstall using the enterprise MSI it leaves the pinned icon. If I use a bat to remove the icon from the directory, the lnk is deleted but there is left a white paper icon on the task bar. So far this is the only code that works on removing the pinned icon.
Option Explicit
Const CSIDL_APPDATA = &H1A
Dim objShell
Dim objFolder
Dim objFolderItem
Dim objVerb
Dim objCurrentUserAppData
Dim strCurrentUserAppData
Set objShell = CreateObject("Shell.Application")
Set objCurrentUserAppData = objShell.NameSpace(CSIDL_APPDATA)
strCurrentUserAppData = objCurrentUserAppData.Self.Path
'===================''==================='
' - Remove All Pinned Items -
'===================''==================='
Set objFolder = objShell.Namespace(strCurrentUserAppData & "\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar")
For Each objFolderItem in objFolder.Items
'WScript.Echo objFolderItem
If objFolderItem = "Google Chrome" then
For Each objVerb in objFolderItem.Verbs
If Replace(objVerb.name, "&", "") = "Unpin from Taskbar" Then objVerb.DoIt
Next
End if
Next
The BATCH Code I have run still will not remove the icon even after rebooting.
taskkill /im chrome.exe /f /t
taskkill /im GoogleUpdate.exe /f /t
taskkill /im GoogleCrashHandler.exe /f /t
taskkill /im GoogleCrashHandler64.exe /f /t
taskkill /im GoogleUpdateBroker.exe /f /t
taskkill /im GoogleUpdateHelper.msi /f /t
taskkill /im GoogleUpdateOnDemand.exe /f /t
taskkill /im GoogleUpdateSetup.exe /f /t
taskkill /im chrmstp.exe /f /t
MsiExec.exe /X{3EDA268B-C905-37D1-89DF-7049B39FB069} /q/n
MsiExec.exe /X{6A21C1E8-DAC1-3C18-BCDC-2DBB4B352AD8} /q/n
rem app files
rd "%userprofile%\AppData\Local\Google" /s/q
rd "C:\Users\Default\AppData\Local\Google" /s/q
rd "\Google" /s/q
rd "%PROGRAMFILES%\Google" /s/q
rd "%PROGRAMFILES(X86)%\Google" /s/q
rem desktop shorcuts
del "%PUBLIC%\Desktop\Google Chrome.lnk" /q
del "%userprofile%\Desktop\Google Chrome.lnk" /q
rem start menu folders
rd "%PROGRAMDATA%\Microsoft\Windows\Start Menu\Programs\Google Chrome" /s/q
rd "%userprofile%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Google Chrome" /s/q
rem pinned items
del "%userprofile%\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\Google Chrome*.lnk" /q
del "%userprofile%\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar\Google Chrome*.lnk" /q
taskkill /f /im explorer.exe
start explorer.exe
Try this hybrid code (Vbscript/PowerShell):
Option Explicit
Dim Title,Ws,ByPassPSFile,AppPath,Example,PSFile,MyCmd,Result,MyArray,MyApp,FolderPath,fso
Title = "UnPin application from Taskbar on Windows 7 by Hackoo"
Set Ws = CreateObject("wscript.Shell")
Set fso = Createobject("Scripting.FileSystemObject")
PSFile = Left(Wscript.ScriptFullName, InstrRev(Wscript.ScriptFullName, ".")) & "ps1"
ByPassPSFile = "cmd /k PowerShell.exe -ExecutionPolicy bypass -noprofile -file "
Example = "C:\Program Files\Google\Chrome\Application\Chrome.exe "
AppPath = InputBox("Enter the path of your application in order to unpin it from the taskbar " & vbcr & "Example : " & vbcr & Dblquote(Example) & "",Title,Example)
If AppPath = "" or IsEmpty(AppPath) Then Wscript.Quit()
MyArray = Split(AppPath,"\")
MyApp = MyArray(UBound(MyArray))
FolderPath = fso.GetParentFolderName(AppPath)
MyCmd = "$sa = new-object -c shell.application" & VbCrlF
MyCmd = MyCmd & "$FolderPath = "& DblQuote(FolderPath) & VbCrlF
MyCmd = MyCmd & "$pn = $sa.namespace($FolderPath).parsename('"& MyApp &"')" & VbCrlF
MyCmd = MyCmd & "$pn.invokeverb('taskbarunpin')"
Call WriteMyPSFile(MyCmd)
Result = Ws.run(ByPassPSFile & PSFile,1,True)
'**********************************************************************************************
Sub WriteMyPSFile(strText)
Dim fs,ts,PSFile
Const ForWriting = 2
PSFile = Left(Wscript.ScriptFullName, InstrRev(Wscript.ScriptFullName, ".")) & "ps1"
Set fs = CreateObject("Scripting.FileSystemObject")
Set ts = fs.OpenTextFile(PSFile,ForWriting,True)
ts.WriteLine strText
ts.Close
End Sub
'**********************************************************************************************
Function DblQuote(Str)
DblQuote = Chr(34) & Str & Chr(34)
End Function
'**********************************************************************************************
EDIT : 22/06/2015 : UnPinfromTaskBarHiddenConsole.vbs
Option Explicit
Dim Title,Ws,ByPassPSFile,AppPath,Example,PSFile,MyCmd,Result,MyArray,MyApp,FolderPath,fso
Title = "UnPin application from Taskbar on Windows 7 by Hackoo"
Set Ws = CreateObject("wscript.Shell")
Set fso = Createobject("Scripting.FileSystemObject")
PSFile = Left(Wscript.ScriptFullName, InstrRev(Wscript.ScriptFullName, ".")) & "ps1"
ByPassPSFile = "cmd /c PowerShell.exe -ExecutionPolicy bypass -noprofile -file "
Example = "C:\Program Files\Google\Chrome\Application\Chrome.exe "
AppPath = InputBox("Enter the path of your application in order to unpin it from the taskbar " & vbcr & "Example : " & vbcr & Dblquote(Example) & "",Title,Example)
If AppPath = "" or IsEmpty(AppPath) Then Wscript.Quit()
MyArray = Split(AppPath,"\")
MyApp = MyArray(UBound(MyArray))
FolderPath = fso.GetParentFolderName(AppPath)
MyCmd = "$sa = new-object -c shell.application" & VbCrlF
MyCmd = MyCmd & "$FolderPath = "& DblQuote(FolderPath) & VbCrlF
MyCmd = MyCmd & "$pn = $sa.namespace($FolderPath).parsename('"& MyApp &"')" & VbCrlF
MyCmd = MyCmd & "$pn.invokeverb('taskbarunpin')"
Call WriteMyPSFile(MyCmd)
Result = Ws.run(ByPassPSFile & PSFile,0,True)
MsgBox "The Unpin of " & DblQuote(MyApp) & " from the taskbar is done !",VbInformation,Title
'**********************************************************************************************
Sub WriteMyPSFile(strText)
Dim fs,ts,PSFile
Const ForWriting = 2
PSFile = Left(Wscript.ScriptFullName, InstrRev(Wscript.ScriptFullName, ".")) & "ps1"
Set fs = CreateObject("Scripting.FileSystemObject")
Set ts = fs.OpenTextFile(PSFile,ForWriting,True)
ts.WriteLine strText
ts.Close
End Sub
'**********************************************************************************************
Function DblQuote(Str)
DblQuote = Chr(34) & Str & Chr(34)
End Function
'**********************************************************************************************
Related
Below mentioned batch file displays InstallDate (Converted):
#echo off
for /f "delims=" %%A in ('WMIC OS GET InstallDate /format:value') do (
#for /f "tokens=2 delims==" %%B in ("%%A") do (
Call :ConvertDate %%B
)>"%temp%\%~n0.txt"
)
for /f "delims=" %%D in ('Type "%temp%\%~n0.txt"') do ( set InstallDate=%%D )
echo Install Date: %InstallDate%
pause
::**********************************************************************
Rem Function for Converting WMI Dates to a Standard Date-Time Format
:ConvertDate <Date>
(
echo WScript.echo WMIDateStringToDate("%~1"^)
echo Function WMIDateStringToDate(Mydate^)
echo WMIDateStringToDate = CDate(Mid(Mydate, 5, 2^) ^& "/" ^& _
echo Mid(Mydate, 7, 2^) ^& "/" ^& Left(Mydate, 4^) _
echo ^& " " ^& Mid (Mydate, 9, 2^) ^& ":" ^& _
echo Mid(Mydate, 11, 2^) ^& ":" ^& Mid(Mydate,13, 2^)^)
echo End Function
)>"%temp%\%~n0.vbs"
cscript /nologo "%temp%\%~n0.vbs" "%~1"
Del "%temp%\%~n0.vbs"
exit /b
Output:
Install Date: 24/05/2020 12:54:28
Now, For this I am trying to create and combine Desire Output like:
Install Date: 24/05/2020 12:54:28 (114 Days Ago)
I have tried several things but failed. is there any way to do this in batch?
Thanks.
As you're already using wsh for your date conversion, you may as well use it to retrieve the wmi information too.
Here's a single hybrid batch-file which should do that for you, without the need to write a vbs file, run it, then delete it:
<!-- :
#"%__APPDIR__%cscript.exe" //NoLogo "%~f0?.wsf"
#Pause & GoTo :EOF
-->
<Job><Script Language="VBScript">
On Error Resume Next
Set objWMIService = GetObject("winmgmts://./root/cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem",,48)
For Each objItem in colItems
dtmInstalled = ParseDat(objItem.InstallDate)
numInstalled = DateDiff("n",dtmInstalled,ParseDat(objItem.LocalDateTime))
numInstDays = (numInstalled \ 60) \ 24
strMessage = "Install Date: " & dtmInstalled
If numInstDays = 0 Then
strMessage = strMessage & " (Today)"
ElseIf numInstDays > 1 Then
strMessage = strMessage & " (" & numInstDays & " Days Ago)"
Else
strMessage = strMessage & " (" & numInstDays & " Day Ago)"
End If
Next
WScript.Echo strMessage
WScript.Quit
Function ParseDat(ByVal strDate)
strYear = Left(strDate,4)
strMonth = Mid(strDate,5,2)
strDay = Mid(strDate,7,2)
strDat = strDay & "/" & strMonth & "/" & strYear
strHour = Mid(strDate,9,2) - strTimeShift
strMins = Mid(strDate,11,2)
strSecs = Mid(strDate,13,2)
strTime = strHour & ":" & strMins & ":" & strSecs
ParseDat = strDat & " " & strTime
End Function
</Script></Job>
As you've made no attempt at calculating the number of days yourself, I will not be explaining any of the above, modifying it, or adjusting it should you decide to modify your question post submission.
I am trying to write a windows batch script that will run all the time and when a usb flash drive will be inserted it will copy files from usb to computer.
I've found a lot of script that do different parts of it but none of them works as I want.
Can sombody help me ?
I posted before a vbscript here to do what you want just take a look and try it !
Vbscript to copy files with specific extension from usb when plugged in
Edit on 19/07/2016 #10:42 :
I improved this vbsript to run as admin, and to let executing just one insctance of this script.
AutoSave_USB_SDCARD.vbs to copy into My Documents folder
Option Explicit
' Run as Admin
If Not WScript.Arguments.Named.Exists("elevate") Then
CreateObject("Shell.Application").ShellExecute WScript.FullName _
, WScript.ScriptFullName & " /elevate", "", "runas", 1
WScript.Quit
End If
' To let executing just one insctance of this script
If AppPrevInstance() Then
MsgBox "There is an existing proceeding !" & VbCrLF &_
CommandLineLike(WScript.ScriptName),VbExclamation,"There is an existing proceeding !"
WScript.Quit
Else
Do
Call AutoSave_USB_SDCARD()
Pause(30)
Loop
End If
'**************************************************************************
Function AppPrevInstance()
With GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\.\root\cimv2")
With .ExecQuery("SELECT * FROM Win32_Process WHERE CommandLine LIKE "_
& CommandLineLike(WScript.ScriptFullName) & _
" AND CommandLine LIKE '%WScript%' OR CommandLine LIKE '%cscript%'")
AppPrevInstance = (.Count > 1)
End With
End With
End Function
'**************************************************************************
Function CommandLineLike(ProcessPath)
ProcessPath = Replace(ProcessPath, "\", "\\")
CommandLineLike = "'%" & ProcessPath & "%'"
End Function
'*************************AutoSave_USB_SDCARD()****************************
Sub AutoSave_USB_SDCARD()
Dim Ws,WshNetwork,NomMachine,MyDoc,strComputer,objWMIService,objDisk,colDisks
Dim fso,Drive,NumSerie,volume,cible,Amovible,Dossier,chemin,Command,Result
Set Ws = CreateObject("WScript.Shell")
Set WshNetwork = CreateObject("WScript.Network")
NomMachine = WshNetwork.ComputerName
MyDoc = Ws.SpecialFolders("Mydocuments")
cible = MyDoc & "\"
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colDisks = objWMIService.ExecQuery _
("SELECT * FROM Win32_LogicalDisk")
For Each objDisk in colDisks
If objDisk.DriveType = 2 Then
Set fso = CreateObject("Scripting.FileSystemObject")
For Each Drive In fso.Drives
If Drive.IsReady Then
If Drive.DriveType = 1 Then
NumSerie=fso.Drives(Drive + "\").SerialNumber
Amovible=fso.Drives(Drive + "\")
Numserie=ABS(INT(Numserie))
volume=fso.Drives(Drive + "\").VolumeName
Dossier=NomMachine & "_" & volume &"_"& NumSerie
chemin=cible & Dossier
Command = "cmd /c Xcopy.exe " & Amovible &" "& chemin &" /I /D /Y /S /J /C"
Result = Ws.Run(Command,0,True)
end if
End If
Next
End If
Next
End Sub
'**************************End of AutoSave_USB_SDCARD()*******************
Sub Pause(Sec)
Wscript.Sleep(Sec*1000)
End Sub
'************************************************************************
This waits for the volumes to change, then copies the USB to c:\test. Lots of message boxes so you can see what's happening. Remove them for production.
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\.\root\CIMV2")
Set evtDevice = objWMIService.ExecNotificationQuery ("SELECT * FROM Win32_VolumeChangeEvent")
Wscript.Echo "Waiting for events ..."
Do
Set objReceivedEvent = evtDevice.NextEvent
'report an event
Wscript.Echo " Win32_Device Changed event occurred" & VBNewLine
If objReceivedEvent.EventType = 1 Then
Wscript.Echo "Type = Config Changed"
ElseIf objReceivedEvent.EventType = 2 Then
Wscript.Echo "Type = Device Arrived"
Set colItems = objWMIService.ExecQuery("Select * From Win32_Volume")
For Each objItem in colItems
Wscript.Echo objitem.DriveType
If objitem.DriveType = 2 then
Wscript.Echo objItem.DriveType & " " & objItem.Name & " " & objItem.driveletter
Wscript.Echo "Starting Copying"
Set objShell = CreateObject("Shell.Application")
Set Ag=Wscript.Arguments
set WshShell = WScript.CreateObject("WScript.Shell")
Set SrcFldr=objShell.NameSpace(objitem.driveletter)
Set DestFldr=objShell.NameSpace("c:\test\")
Set FldrItems=SrcFldr.Items
DestFldr.CopyHere FldrItems, &H214
Wscript.Echo "Finished Copying"
End If
Next
ElseIf objReceivedEvent.EventType = 3 Then
Wscript.Echo "Type = Device Left"
ElseIf objReceivedEvent.EventType = 4 Then
Wscript.Echo "Type = Computer Docked"
End If
Loop
Try this:
#echo off
set backupcmd=xcopy /s /c /d /e /h /i /r /y /
%backupcmd% "%USERPROFILE%\Pictures" "%drive%\all\My pics"
%backupcmd% "%USERPROFILE%\Favorites" "%drive%\all\Favorites"
%backupcmd% "%USERPROFILE%\Videos" "%drive%\all\Vids"
%backupcmd% "%USERPROFILE%\Documents" "%drive%\all\Docs"
%backupcmd% "%USERPROFILE%\OneDrive" "%drive%\all\Onedrive"
%backupcmd% "%USERPROFILE%\Desktop" "%drive%\all\Desktop"
%backupcmd% "%USERPROFILE%\Network" "%drive%\all\Other devices"
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I have directory with executable files like
tool-7.0.20.exe
tool-7.0.23.exe
tool-7.0.24.exe
tool-7.0.25.exe
tool-7.0.26.exe
and I'm using a for loop in a batch file to get the latest version in a variable and run it
I need to convert this for loop to a vbs script
for /f "tokens=*" %%a in ('dir /ON /B %~dps0tool*.exe') do set latest=%%a
then run the latest file variable with objShell.Exec or objShell.Run
Thanks
You can do it using Shell.Application ActiveX:
Option Explicit
Const SHCONTF_NONFOLDERS = &H40
Const SHCONTF_INCLUDEHIDDEN = &H80
Dim strCurDir, strPath, objWshShell
strCurDir = Left(WScript.ScriptFullName, InStrRev(WScript.ScriptFullName, "\"))
With CreateObject("Shell.Application").Namespace(strCurDir).Items
.Filter SHCONTF_NONFOLDERS + SHCONTF_INCLUDEHIDDEN, "tool-*.exe"
strPath = .Item(.Count - 1).Path
End With
WScript.Echo strPath
Set objWshShell = CreateObject("WScript.Shell")
objWshShell.Run strPath
Or by retrieving files with Scripting.FileSystemObject and filtering them with VBScript.RegExp:
Option Explicit
Dim strFiles, objMatches, strPath, objWshShell
With CreateObject("Scripting.FileSystemObject")
With .GetFolder(.GetParentFolderName(WScript.ScriptFullName))
strFiles = ""
For Each strPath In .Files
strFiles = strFiles & strPath & vbCrLf
Next
End With
End With
With CreateObject("VBScript.RegExp")
.Global = True
.MultiLine = True
.IgnoreCase = True
.Pattern = "^.+?\\tool-.*?\.exe$"
Set objMatches = .Execute(strFiles)
strPath = objMatches(objMatches.Count - 1).Value
End With
WScript.Echo strPath
Set objWshShell = CreateObject("WScript.Shell")
objWshShell.Run strPath
Or even running your cmd code (cmd instructions were slightly modified to be executed in one liner command line mode):
Option Explicit
Dim objWshShell, strCurDir, strCmd, strRes
Set objWshShell = CreateObject("WScript.Shell")
strCurDir = Left(WScript.ScriptFullName, InStrRev(WScript.ScriptFullName, "\"))
strCmd = "%comspec% /v /c (for /f %a in ('dir /ON /B /S " & strCurDir & "tool-*.exe') do #set latest=%a)&echo !latest!"
strRes = objWshShell.Exec(strCmd).StdOut.ReadAll()
strRes = Replace(strRes, vbCrLf, "")
WScript.Echo strRes
objWshShell.Run strRes
If you want to get rid of the flashing console window, the above code may be modified as follows to launch second instance of the script in hidden mode, and execute cmd instructions within it:
Option Explicit
Dim objWshShell, strCurDir, strCmd, strRes, objWnd, objParent, strSignature
Set objWshShell = CreateObject("WScript.Shell")
If WScript.Arguments.Named.Exists("signature") Then WshShellExecCmd
strCurDir = Left(WScript.ScriptFullName, InStrRev(WScript.ScriptFullName, "\"))
strCmd = "%comspec% /v /c (for /f %a in ('dir /ON /B /S " & strCurDir & "tool-*.exe') do #set latest=%a)&echo !latest!"
RunCScriptHidden
strRes = Replace(strRes, vbCrLf, "")
WScript.Echo strRes
objWshShell.Run strRes
Sub RunCScriptHidden()
strSignature = Left(CreateObject("Scriptlet.TypeLib").Guid, 38)
GetObject("new:{C08AFD90-F2A1-11D1-8455-00A0C91F3880}").putProperty strSignature, Me
objWshShell.Run ("""" & Replace(LCase(WScript.FullName), "wscript", "cscript") & """ //nologo """ & WScript.ScriptFullName & """ ""/signature:" & strSignature & """"), 0, True
End Sub
Sub WshShellExecCmd()
For Each objWnd In CreateObject("Shell.Application").Windows
If IsObject(objWnd.getProperty(WScript.Arguments.Named("signature"))) Then Exit For
Next
Set objParent = objWnd.getProperty(WScript.Arguments.Named("signature"))
objWnd.Quit
objParent.strRes = objWshShell.Exec(objParent.strCmd).StdOut.ReadAll()
WScript.Quit
End Sub
Supposedly I want to delete logfiles from the C:\ drive. (XXX-Log1.log XXX-Log2.log)
Question: if a file is deleted (I'm just using the del /f /q C:\*.log command), there's obviously no output.
How can I write output to a logfile when a file is deleted and only then? I know for writing to a logfile you can use >>"D:\What\Ever\Deleted.log", but I'd like to have displayed which files were deleted, if any.
If the folder does not have any subdirectories, then this will work:
#echo off
setlocal enableextensions
del /s "c:\folder\*.log" >file.log
pause
Here is a vbscript you can use to monitor a folder for deletion events. This might do what you want. Just call it with cscript like cscript /nologo monitorfolder.vbs You'll need to edit it to monitor in your path. I just used my C:\temp folder for testing.
MonitorFolder()
Function MonitorFolder()
intInterval = "2"
strDrive = "C:"
strFolder = "\\temp\\"
strComputer = "."
Set objFS = CreateObject("Scripting.FileSystemObject")
Set objFile = objFS.CreateTextFile("C:\temp\Deleted.log")
Set objWMIService = GetObject( "winmgmts:" & _
"{impersonationLevel=impersonate}!\\" & _
strComputer & "\root\cimv2" )
strQuery = _
"Select * From __InstanceOperationEvent" _
& " Within " & intInterval _
& " Where Targetinstance Isa 'CIM_DataFile'" _
& " And TargetInstance.Drive='" & strDrive & "'" _
& " And TargetInstance.Path='" & strFolder & "'"
Set colEvents = objWMIService.ExecNotificationQuery (strQuery)
WScript.Echo "Monitoring events...[Ctl-C] to end"
Do
Set objEvent = colEvents.NextEvent()
Set objTargetInst = objEvent.TargetInstance
Select Case objEvent.Path_.Class
Case "__InstanceDeletionEvent"
objFile.WriteLine(objTargetInst.Name)
End Select
Loop
End Function
The batch changes the vbs code making it unreadable for the vbs to use. How do i fix this?
Batch code:
echo Const HIGH = 128 >> prio.vbs
echo strComputer = "." >> prio.vbs
echo Set objWMIService = GetObject("winmgmts:" _ >> prio.vbs
echo & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") >> prio.vbs
echo Set colProcesses = objWMIService.ExecQuery _ >> prio.vbs
echo ("Select * from Win32_Process Where Name = 'file.exe'") >> prio.vbs
echo For Each objProcess in colProcesses >> prio.vbs
echo objProcess.SetPriority(HIGH) >> prio.vbs
echo Next >> prio.vbs
VBS orginal:
Const HIGH = 128
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colProcesses = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = 'file.exe'")
For Each objProcess in colProcesses
objProcess.SetPriority(HIGH)
Next
VBS After :
Const HIGH = 128
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
Set colProcesses = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = 'file.exe'")
For Each objProcess in colProcesses
objProcess.SetPriority(HIGH)
Next
help please
& characters have a special meaning in CMD (command-chaining), so you have to escape them to get literal ampersands:
echo ^& "{impersonationLevel=impersonate}!\\" ^& strComputer ^& "\root\cimv2") >> prio.vbs
The same is also true for closing parenthesis ')' and '<', '>'
You don't need to create another file, also, don't need any escaping to do it if you can save your vbs code with bat hybrid format:
<!-- :
#echo off && mode 050,03 && title <nul && title .\%~nx0
for /f ^tokens^=* %%i in ('%__APPDIR__%wScript.exe "%~dpnx0?.wsf" ^& cls')do exit /b 2>nul >nul
--> <job> <script language = "vbscript">Const HIGH = 128 : strComputer = ".": Set objWMIService = GetObject("winmgmts:" &_
"{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2"): Set colProcesses = objWMIService.ExecQuery ("Select *"&_
"from Win32_Process Where Name = 'file.exe'"): For Each objProcess in colProcesses: objProcess.SetPriority(HIGH): Next </script></job>
So, don't need any escaping, just execute in command line or click then!
About layout:
<!-- :
#echo off && mode 050,03 && title <nul && title .\%~nx0
for /f ^tokens^=* %%i in ('%__APPDIR__%wScript.exe "%~dpnx0?.wsf" ^& cls')do exit /b 2>nul >nul
--> <job> <script language = "vbscript">
:: your vbs code here ::
</script></job>