How to Input Keys using vbscript Into Batch
Is there a way to make a VBScript input alt+enter to a batch file that has already been executed? (batch file>VBScript(input alt+enter)>batch file)
See also questions close to this topic
Windows batch: replace strings in a file case sensitively
I've spent a lot of time writing a script to generate new files using a "template" (coding env.) project.
While on Unix the shell script is laughably easy I spent days doing the same on Windows...
My current batch file does almost everything I need, except that the string replacement is case-insensitive... That is, it replaces "emptyproject" with "EMPTYPROJECT", being the first statement...
@echo off & setlocal ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION set argc=0 for %%x in (%*) do set /A argc+=1 if /I "%argc%" EQU "0" ( echo Usage: %0 PROJECT_NAME >&2 exit /B 1 ) set curr_dir=%~dp0 set project_name=%1 set project_name_lower=%1 set project_name_upper=%1 set project_file="vstudio\projects\%project_name%.vcxproj" set project_filters="vstudio\projects\%project_name%.vcxproj.filters" call :toupper project_name_upper call :tolower project_name_lower if not exist %project_file% ( copy /y "vstudio\projects\EmptyProject.vcxproj" %project_file% >nul copy /y "vstudio\projects\EmptyProject.vcxproj.filters" %project_filters% >nul ) set project_source_dir=..\projects\source\%project_name_lower% if not exist %project_source_dir% ( mkdir %project_source_dir% call :copy_and_replace_strings "..\projects\source\emptyproject\main.cpp" "%project_source_dir%\main.cpp" %project_name% %project_name_lower% %project_name_upper% call :copy_and_replace_strings "..\projects\source\emptyproject\emptyproject.h" "%project_source_dir%\%project_name_lower%.h" %project_name% %project_name_lower% %project_name_upper% call :copy_and_replace_strings "..\projects\source\emptyproject\emptyproject_main.cpp" "%project_source_dir%\%project_name_lower%_main.cpp" %project_name% %project_name_lower% %project_name_upper% call :copy_and_replace_strings "..\projects\source\emptyproject\emptyproject_eventhandlers.cpp" "%project_source_dir%\%project_name_lower%_eventhandlers.cpp" %project_name% %project_name_lower% %project_name_upper% ) endlocal goto :EOF REM functions :toupper for %%L IN (A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) DO SET %1=!%1:%%L=%%L! goto :EOF :tolower for %%L IN (a b c d e f g h i j k l m n o p q r s t u v w x y z) DO SET %1=!%1:%%L=%%L! goto :EOF :copy_and_replace_strings <source_file> <target_file> <name> <lower> <upper> for /f "tokens=1,* delims=]" %%a in ('find /n /v "" ^< %1') do ( set token1=%%a set token2=%%b if defined token2 ( REM not case sensitive set token2=!token2:EMPTYPROJECT=%5! set token2=!token2:EmptyProject=%3! set token2=!token2:emptyproject=%4! echo !token2!>>%2 ) else ( echo[>>%2 ) ) goto :EOF
I read a lot about this on this forum, but couldn't find a suitable solution. Could someone help me please?
windows batch copy command not working
windows batch copy cmd alone not working properly
@echo off FOR /F "tokens=2-4 delims=/ " %%i IN ('date /t') DO SET DATE=%%k%%i%%j REN \\server1\vinoth_new\vinoth\Test"*.txt*" SubroQuePrint.txt copy \\server1\vinoth_new\vinoth\Test\SubroQuePrint.txt \\server1\vinoth_new move /Y \\server1\vinoth_new\SubroQuePrint.txt \\server1\vinoth_new\Test\%DATE%SubroQuePrint.txt
Batch script for /f loop does not show all tokens
I have weather.txt
January,Snowy,02 February,Rainy,15 March,Sunny,25
@echo off for /f "tokens=1,3 delims=," %%M in (weather.txt) do (echo %%M %%T)
I expect output
January 02 February 15 March 25
But I get
January %T February %T March %T
Vbs script file is not Executing(Running) while clicking the .vbs file
I have The scenario like deleting files from some particular path and save the deleted file name in .csv file .It is running perfectly when I am running thru developer script inside excel file but it is not running when am directly executing the .vbs file also I tried using cmd script.
InputFilePath = "C:\Users\Desktop\vba\FoldersCleanupInput.xlsx" ' Create the Excel object On Error Resume Next Set objExcel = CreateObject("Excel.Application") If (Err.Number <> 0) Then Exit Sub End If ' Don't display any alert messages objExcel.DisplayAlerts = 0 ' Open the document as read-only On Error Resume Next Call objExcel.Workbooks.Open(InputFilePath, False, True) If (Err.Number <> 0) Then Exit Sub End If ' If you wanted to read all sheets, you could call ' objExcel.Worksheets.Count to get the number of sheets ' and the loop through each one. But in this example, we ' will just read the first sheet. Set objSheet = objExcel.ActiveWorkbook.Worksheets(1) Set objSheet2 = objExcel.ActiveWorkbook.Worksheets(2) ' Get the number of used rows nUsedRows = objSheet.UsedRange.Rows.Count ' Get the number of used columns nUsedCols = objSheet.UsedRange.Columns.Count ' Get the topmost row that has data nTop = objSheet.UsedRange.Row ' Get leftmost column that has data nLeft = objSheet.UsedRange.Column ' Get the used cells Set objCells = objSheet.Cells Set objSheet2Cells = objSheet2.Cells logpath = objSheet2Cells(1, 2).Value numberOfDays = objSheet2Cells(2, 2).Value If objFSO.FileExists(logpath) Then Set objFile = objFSO.OpenTextFile(logpath) Else Set objFile = objFSO.CreateTextFile(logpath, True) Set objFile = objFSO.OpenTextFile(logpath) End If 'Open logpath For Output As #1 ' Dimension the sheet array ReDim arrSheet(nUsedRows - 1, nUsedCols - 1) ' Loop through each row For nRow = 0 To (nUsedRows - 1) ' Loop through each column For nCol = 0 To (nUsedCols - 1) For Each oFile In objFSO.GetFolder(objCells(nRow + nTop, nCol + nLeft).Value).Files If oFile.DateLastModified < (Now() - numberOfDays) Then 'Dim i As Integer ' Print #1, "Deleted File Name:" & oFile & "Deleted on:" & Date & " " & Time Set dd = "Deleted File Name:" & oFile & "Deleted on:" & Date & " " & Time objFile.WriteLine dd oFile.Delete (True) End If Next Next Next 'Close #1 ' Close the workbook without saving Call objExcel.ActiveWorkbook.Close(False) ' Quit Excel objExcel.Application.Quit Close objFile End Sub
Please suggest me to solve the issue .Thanks in Advance.
How to password protect my excel sheet after saving them using vb script
I want to password protect my excel sheet after saving it through vb scripting. I tried using this code but I get an error:
How to enter values from inputbox in excel and store them in newline using vbscript every time
I am trying to add values from an InputBox to Excel worksheet cells which I have created using VBScript.
I am able to store values in worksheet cells whenever I am entering the values in InputBox but my issue is that I have hardcoded the cell values and by using that I have assigned values to my InputBox that where to put the InputBox data in worksheet cells so whenever I am running my vbs file it is replacing the old values stored in those particular cells but instead I want to make it like every time I run my VBScript it will store the InputBox data in a new line and will also keep the old entries in worksheet cells saved but I am not sure how to do that.
Below is my code for your reference:
sInput = InputBox("Enter your name") MsgBox ("You entered:" & sInput) sInput1 = InputBox("Enter your name") MsgBox ("You entered:" & sInput) Set objExcel = CreateObject("Excel.Application") Set objWorkbook = objExcel.Workbooks.Open("C:\Users\saurabh.ad.sharma\Desktop\rrr.xlsx") objExcel.Application.Visible = True objExcel.Cells(1,1).Value= sInput objExcel.Cells(1,2).Value= sInput1 objExcel.ActiveWorkbook.Save objExcel.ActiveWorkbook.Close objExcel.Application.Quit WScript.Echo "Finished." WScript.Quit