Windows Batch

12K

Solutions

11K

Contributors

Batch files are text files containing a script of commands that are executed by the command interpreter on DOS, OS/2 and Windows systems. Most commonly, they are used to perform a series of functions that are repeated -- copying a set of files created daily with one step, for example.

Share tech news, updates, or what's on your mind.

Sign up to Post

I want to install from command line (script), and MSIE add-on, which is a cab file stored on internal web server.
The cab contains two files:
abwxprint.ocx
abwxprint.inf

The inf contains, that:
[version]
    signature="$CHICAGO$"
    AdvancedINF=2.0
[Add.Code]
    abwxprint.ocx=abwxprint.ocx
[abwxprint.ocx]
    file-win32-x86=thiscab
    clsid={226D14C3-DEA2-4F68-9CD3-3837439AF7DE}
    FileVersion=1,0,0,1
    RegisterServer=yes


I see on Internet, different solutions, but nothing works.
rundll32.exe advpack.dll,....
pkgmgr ...
I've tried to copy the two files, on "C:\Windows\Downloaded Program Files", to register the ocx with the regsvr32.exe command.
After that, the add-in is in the add-ins MSIE list, but is disabled.
I don't know how to enable it with command line?

My purpose is to automate the add-in installation, directly without GPO (I have another tool to teledistribute, an automate some actions).

Thank you for your help.

Jm
0
Become a Microsoft Certified Solutions Expert
LVL 13
Become a Microsoft Certified Solutions Expert

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

looking for replacement the old 32 bit TOUCH program to change by commandline the date for file   like it was in dos
its not running in 64 bit

touch j:\*,*   or touch j:\*.txt    will files selected to today date
0
Can someone please help us with a bat script that will wait 5 minutes and then return a 0 on success?

We need to call the script from this registry key : HKLM\Software\Citrix\MachineIdentityServiceAgent\ImagePreparation\After

The values are expected to be an executable or script (bat), returning 0 on success

Basically we need to VM to wait 5 minutes before it's shutdown by the system on returning a 0 on success the shutdown will triggered.  

Thank you!
0
I need a custom script or batch written to check for the existence of two daily files that should exist for the next day. More specifically, we have a scheduler system that should be exporting a proprietary file for the next day. If this file does not get created then someone needs to be alerted prior to midnight when that file would need to be used. The scheduler is creating two files for each day so we would need to check for both. The format of the files is MEGA%MM%%DD% and BLAZE%MM%%DD%, where %MM% is the 2-digit month and %DD% is the 2-digit day of the month. Example of files: MEGA0913 and BLAZE0913. Neither file has a file extension so Windows just sees them as a type 'file'. I plan on using task scheduler to check for both files at 9pm of the day before. So on the 13th, the script would run at 9pm and be looking for MEGA0914 and BLAZE0914. Both files reside in the same folder. If either of the files is missing then the script needs to send an email, using BLAT or similar to alert an email address as to which file(s) are missing.
0
Someone from another organization told me he has an
in-house developed script that could read incoming emails
(in particular those originating from outside the organization)
for URLs/links, originating IP & attachments: the script will
extract the links, IP & attachments, check them in virustotal
& hold back the email if it's a known IOC by any of the
security products in VT.

I have a tool from VT (vt.exe) that could post IP, hashes
& links to VT but I don't know how to extract the links,
attachments & originating IP of emails.

The acquaintance cant share the script as their intellectual
property: they used in on their on-prem Exchange.

Anyone can share any free tools, batch or VB scripts ?
Ideally not a PS script but if it has to be a PS script, then
I'll take it as well.

We are using MS Exchange Online.


One more feature to add in:
will be nice if the script could check if the originating
IP belongs to the sender's domain (which is visible
to the email recipient) & if not hold back the email
as well & notify our IT support by email
0
Hi,
I am trying to enable TCP/IP and Named Pipes using the following command. But I have encountered the error:--

WMIC /NAMESPACE:\\root\Microsoft\SqlServer\ComputerManagement10 PATH ServerNetworkProtocol Where ProtocolName=’Np’ CALL SetEnable

Please see the attachment.

Thanks
Capture.PNG
0
I have created batch job to copy a file to UNC path, which is mapped to my computer. The batch job run from task scheduler but the file doesn't transfer to UNC path. But if I run command manually is successfully copy files. I have tried both batch below:
####################################
  @echo off
pushd c:\xxx\zzzz\yyyyyy\
COPY * Q:\test\--(note:this is the map drive letter for unc path)
Sleep 5
popd
end
cls
################################################
@echo off
cd c:\xxx\zzzz\yyyyyy\
move * Q:\test\--(note:this is the map drive letter for unc path)
sleep 5
del *
#end
exit



Action Started
Task Scheduler launched action "C:\Windows\SYSTEM32\cmd.exe" in

instance "{90e9b280-15df-4a79-9ec1-6bef9a621423}" of task

"\xxxxxx".

Action completed
Task Scheduler successfully completed task "\xxxxxx" , instance

"{90e9b280-15df-4a79-9ec1-6bef9a621423}" , action "C:\Windows

\SYSTEM32\cmd.exe" with return code 0.
0
Dear All

 
               How do i remove reg key without asking yes or no ? i have put /f at the back of the command but doesnt look like correct, i want to create a login bat to GPO, any help would be appreicated

1
0
Hi all,

First of all I'm don't know a lot about scripting and that's the reason I'm here requesting some assistance. So here I go:

We do have a GPO that runs a logon script (batch file that then runs a PS1). The whole purpose is to create shortcuts on the folder redirected desktop of such users (on a Citrix server environment) if they belong to those groups.
The problem we are facing is that sometimes the shortcut will not get created. Based on troubleshooting it seems this script is not the most efficient way to accomplish this task and basically the reason why it doesn't get created is because it times-out. Every day we get calls that the shortcut was not created and most of the time running a GPUPDATE or login the user off/on corrects the problem.

So here I'm asking is a better way to accomplish this task? Please let me know.

REM ---------------
REM -Version Check-
REM ---------------
echo f |XCOPY "\\company-file1\apps\ClientApp\CA\rtclient.exe" "%appdata%\Clientapp\CA\caclient.exe" /D /y /f /e
echo f |XCOPY "\\company-file1\apps\ClientApp\CA\ClientAppUpgradeFix.bat" "%appdata%\ClientApp\CA\ClientAppUpgradeFix.bat" /D /y /f /e
REM -------------------
REM -End Version Check-
REM -------------------

Powershell.exe -executionpolicy remotesigned -file \\company.corp\SysVol\company.corp\Policies\{F144FEB7-BEEA-49C8-B421-3A0F1A089776}\User\Scripts\Logon\UserValidate-Profile.ps1


It then runs that PS1 powershell

Import-Module ActiveDirectory
0
Hi

I am looking for script (powershell, VB or batch) that would stop worker services (abc1,abc3, abc4, cove1, cove2) that are running under system account sys_abc_app and sys_cove_app.  The same script should be able to delete from Appdata\ Local\Temp\ folders directories and subfolders older than 20 days. These Appdata\ Local\Temp\ folders and subfolder are located under each system service account (sys_abc_app and sys_cove_app) that’s why worker services (abc1,abc3, abc4, cove1, cove2) have to be stoppen in order to remove temp folders.

Here are example how these temp folders look like.
C:\Users\sys_abc_app \AppData\Local\Temp\Worker[abc1—Worker1]20190612 192313
C:\Users\sys_abc_app \AppData\Local\Temp\Worker[abc2—Worker2]20190612 192548
C:\Users\sys_abc_app \AppData\Local\Temp\Worker[abc3—Worker3]20190613 061755
C:\Users\sys_abc_app \AppData\Local\Temp\ Worker[abc4—Worker3]20180129 182440
C:\Users\ sys_cove_app \AppData\Local\Temp\Worker[cove1]20180129 203409
C:\Users\ sys_cove_app \AppData\Local\Temp\Worker[cove2]20180129 45334
C:\Users\sys_cove_app\AppData\Local\Temp\ Worker[cove2]20180129 45334535
And soon on.

1.      The script should pull worker service names from TEXT file.
2.      Script should stop worker services.
3.      Script should removal folders older then 20 days by checking date stamp
4.      Once the removal is complete the same script should start stopped services from the TEXT file.
5.      Script should send or generate csv file( a report )of these folders…
0
C++ 11 Fundamentals
LVL 13
C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

I had this question after viewing batch file to add map driver for network location and ask for credential.

I have two "DC" and now I'm trying to create a batch or shortcut to DC2  to be map to other folders.
net.exe use X: \\APPS \PCC storage * /user:DC2\myname /persistent:no
Is this fine
or another below statement..

@echo off
if Not exist y:\ (

echo Please enter User ID:
set /p USERID=

echo Please enter your Password:
set /p PASSWORD=


cmdkey.exe /add:APPS.US /user:dc2\myname /pass:%PASSWORD%


net use O: "\\APPS\PC1 storage" /persistent:YES
pause
)
1
I have few OS commands which I need to run only through ADMINISTRATOR's CMD console
please advice how to call such batch script

example :TEST.BAT
how to make sure below  script called from admin cmd console
==

echo " Hello"

==
0
Dear All


             i have made below bat file to client desktop, and found that 1 computer showing the wrong ip address after click on the bat file, the ip show the old DC & DNS server, any idea what goes wrong ? any idea to get it fix and showing the real computer ip address ?


@echo off
REM myip.bat
REM script to return just the IP address of the current host.
REM Works on Windows 2000 / Windows XP
COLOR 4f
REM TYPE "FOR /?" AT THE COMMAND PROMPT TO GET DETAILS REGARDING THIS COMMAND LINE.
REM NOTE THE SINGLE BACK QUOTES ARE THE ONES BELOW THE ~ KEY ON THE KEYBOARD.
FOR /F "usebackq tokens=2 delims= " %%i in (`nslookup %computername%`) do set myip=%%i
ECHO.
Echo IP Finder
ECHO -----------------------------------

ECHO My IP Address Is: %MYIP%
Echo.
ECHO My Computer Name Is: %COMPUTERNAME% 
ECHO -----------------------------------
@pause

Open in new window

Keith
0
I am wondering if it is possible to change a line in an ini file using a batch script to a specific directory on a drive
0
Hello,
when a batch-file is executed in cmd. I want to make sure that exactly one parameter has been passed.
How can I do this?
0
I want to install the SCCM agent on a list of computers listed in the text file  c:\temp\list.txt from my computer using the command below.

PSEXEC @”:C\temp\list.txt” –d –h –s –c  “C:\temp\sccmclient.bat”

The sccmclient.bat should do the following
Run this command
CCMSETEP.EXE SMSSITECODE=ABC

The ccmsetup.exe is in a shared folder on \\fileserver1\share1\ccmsetup.exe

I want to run this command with elevated privileges so want to include username and password in the above PSEXEC command.
I tried it with quotes, without quotes but looks simple but this thing does not work.
Appreciate some help
0
I am trying to run procedure in cshtml and want to run one procedure automatically.  Dont want to use windows service or batch file as it is not really working.

i am using something like this in the batch file which runs every hour
start "<C:\Program Files\Internet Explorer\iexplore.exe>" http://10.180.8.5:9093/Feature/DownloadFeatures 

at one point it says completed successfully but it is not doing anything ie. not running the downloadfeatures method. Can you please help? Any automated tool i need to use to run this cshtml file?
0
I have a scheduled task that runs a batch file.  The batch file has several lines where I do a "git pull" command from a specific Git repository.  The Windows server where this runs has already been configured with proxy settings so that when you run "git pull" or any "git" command, it will properly connect to the required repository and run the command.  I have figured out that this schedule task and batch file will run just fine when a user is logged on.  But if I log out of the server, the schedule task start, but the "git pull" command gets stuck.  It's almost like it's can't connect and then the rest of the batch file will not run.  What should I do to ensure the "git" commands run fine even when a user is not logged in?

Thanks in advance!
-Christian
0
Hi there,

I have a scheduled task with these properties:

User account to run the task: A Service account that has logon as batch file privileges
Run whether user is logged on or not is enabled
Run with highest privileges is enabled
Configured for Windows Server 2012 R2
Trigger: Runs hourly
Actions values:
  • Action: Start a program
  • Program/script: Powershell.exe
  • Arguments: -command "Start-Process  C:\Build.bat -Verb runas"
  • Start in: C:\SDS_IT\

Now the problem I am having is that even though I have set the task to run whether user is logged on or not, it never completes unless the user is actually logged on.  If it I log out, the task starts and it gets to about 95% done and then it just gets stuck.  I've tested this theory several times and this is always the case.  I'm confused as to why it's not working.  The service account has local administrative permissions on this VM too.  I'm using PoweShell because I want the script to run a command prompt as administrator.

Any thoughts????
Thank you in advance!
-Christian
0
Build an E-Commerce Site with Angular 5
LVL 13
Build an E-Commerce Site with Angular 5

Learn how to build an E-Commerce site with Angular 5, a JavaScript framework used by developers to build web, desktop, and mobile applications.

How to get count of system dump file from control panel through batch script?
It has to select the path as control panel->system security-> system->advanced system settings->startup and recovery->settings-> dump file count

we have to run this script in background, every time when dump create it has to show the count.

And each time it has to save the dump files to some other folder, when dump created..
0
I had this question after viewing SID account to username.

I tried creating the batch file to run through a text file with SIDs in it. This is what i came up with

@echo off
>output.txt (
for /f %%i IN (unresolvedsids.txt) DO C:Desktop\psgetsid.exe %%i
)

When i run it, it creates an empty output file, this is my first attempt at a batch file so i'm not very sure how to troubleshoot what is happening behind the scenes when you click the .bat file
0
What is the command line, within a batch, if possible, to start that batch in Administrator mode?
Or would another batch be needed to trigger this batch in Administrator?
0
I would like to change the script below, to produce a different output.  

Here is the file that contains the data to use.
C:\Users\user\Desktop\Folder\file.txt

ISA*11*          *22*          *33*1234567891234  *BB*ABCDEFGDH       *181127*3445*¬*00100*000000500*1*Q*:!
GS*PO*0012345678912*JDJDLSLA*20181127*3445*600*A*001234!
ST*850*78945611!
BEG*11*AB*12345**20181127!
N1*CD*COMP*LA*0012345678901!
N3*1 Street Drive!
N4*Pineland*OL*12345*US!
N1*AJ*SOMECOMPANY!
N1*TJ*Company Corp*2*456363748!
N3*1 Street Road!
N4*City, Somewhere**12345*u!
N1*AC*Company*2*987654321!
N3*1234 Street Blvd!
N4*Someplace*NY*12345*US!
N1*YG*Company Name*AL*0012345678912!
N3*5 Place Drive!
N4*Ackanhaw*MI*654321*US!
PO1**151*CA***IN*5465*CR*789456*GG*55555*EQ*Case(s)!
PID*F****Description One!
CTT*3****5*PQ!
SE*30*1234567!
GE*5*500!
IEA*1*000004567!


Here is the current script:
$InputFile = "C:\Users\user\Desktop\Folder\file.txt"
$OutputFile = "C:\Users\user\Desktop\Folder\fileR.txt"

Function ParseText ($OutputFile,$InputFile){
Begin{
        $line,$poline,$shipto,$totline,$total,$i,$n3 = $null,$null,$null,$null,$null,0,0
            Set-Content $OutputFile $null
            $Data = Get-Content -Path $InputFile | ?{$_ -match "(BEG\*)|(PO1\*)|(PID\*)|(N\d\*)|(IEA\*)"}
       }
 Process{
       $Data | % {
       #Check the end of data set
             If ($_ -match "IEA\*"){
                   If($poline -ne $null -and $total -ne $null){
                         

Open in new window

0
I am new to Automation testing, i have to write automation scripts for File Router service, this service has a source/input folder and a destination folder, based on the file name, extension the file(s) will be moved to respective destination.

This is a windows service. based on the configuration this router will move the files

What will be better technology stack for this requirement, when i run the tests , they should be able to copy, verify whether it is copied or not
0
Using Windows batch how can I rename up to 4 files, 1.pdf, 2.pdf, 3.pdf and 4.pdf all based on time stamp, 1.pdf being the file with the earliest time stamp..

At C:\Attachment\.... there could be several files all names differently, but all. pdf files.  
I want to rename each file based on when they were created etc..
0

Windows Batch

12K

Solutions

11K

Contributors

Batch files are text files containing a script of commands that are executed by the command interpreter on DOS, OS/2 and Windows systems. Most commonly, they are used to perform a series of functions that are repeated -- copying a set of files created daily with one step, for example.