Is there something better than using MSDOS in a bat file to run commmand line operations and copy files around.
I am running into the old chestnut "gotchas" with long file names etc - and for some reason the bat file wont pause - when I insert PAUSE in my script after running a command - it's just annoying.
Whats better out there?
Cheers folks.
BTW - Just looked at Powershell and looks like the network/sys admin has blocked Powershell on our PCs (nice).
Take a look at PowerShell
There are a few rules of thumb when working with bat files.
Example: quicksql.bat
@echo off
setlocal
if "%1"=="" goto USAGE
set server=%1
if "%2"=="" goto USAGE
set database=%2
if "%3"=="" goto USAGE
set script=%3
sqlcmd.exe -S %server% -d %database% -i "%script%"
goto EOF
:USAGE
echo %0 server database script
:EOF
endlocal
Actually, answers referring to VBScript really mean Windows Scripting Host:
WSH is a language-independent scripting host for 32-bit Windows platforms. Microsoft provides both Microsoft Visual Basic Script and Java Script scripting engines with WSH. It serves as a controller of ActiveX scripting engines, just as Microsoft Internet Explorer does. Because the scripting host is not a full Internet browser, it has a smaller memory footprint than Internet Explorer; therefore, WSH is appropriate for performing simple, quick tasks. Scripts can be run directly from the desktop by double-clicking a script file, or from a command prompt. WSH provides a low-memory scripting host that is ideal for non-interactive scripting needs such as logon scripting, administrative scripting, and so on. WSH can be run from either the protected-mode Windows-based host (Wscript.exe), or the real-mode command shell-based host (Cscript.exe).
Any windows language (besides vbs and js) that has access to good old COM (ActiveX) can use the same scripting objects. Python is one example, and .NET with P-Invoke is another.
The Script Center Script Repository on technet contains many examples of WSH usage in system administration, most in VBS.
VB Script in a plain .vbs file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With