|23 Aug 2010||#11|
I'm not sure why they are not expanding. Nothing really seems ODD or out of place. I did quickly try building some paths from nested variables, and didn't really have any problems getting them to expand. There are some batch paramaters you can use to expand paths
%~1 Expands %1 and removes any surrounding quotation marks (""). %~f1 Expands %1 to a fully qualified path name. %~d1 Expands %1 to a drive letter. %~p1 Expands %1 to a path. %~n1 Expands %1 to a file name. %~x1 Expands %1 to a file extension. %~s1 Expanded path contains short names only. %~a1 Expands %1 to file attributes. %~t1 Expands %1 to date and time of file. %~z1 Expands %1 to size of file. %~$PATH:1 Searches the directories listed in the PATH environment variable and expands %1 to the fully qualified name of the first one found. If the environment variable name is not defined or the file is not found, this modifier expands to the empty string.
Main thing is, its hard to troubleshoot something when you don't post what is actually there, as their might simply be ; or a % missing that is causing the problem.
I'm sure you've been there, when you've debugged something for 5 hours, ready to throw the PC out the window and write yourself off as a programmer, only to later realize that you forgot one letter in a function, or left off a semi colon.
But here is an example of a question just answered on Server Fault
Batch Script With SQLCMD Usage
up vote 0 down vote favorite
Hi All I am Writing a Batch Script Which has to read a set of SQL Files which exists in a Folder then Execute Them Using SQLCMD utiliy.
When I am Trying to execute it does not create any output file. I am not sure where I am wrong and I am not sure how to debug the script. Can someone help me out with script?
FOR %F IN (C:\SQLCMD\*.SQL) DO sqlcmd -S LENOVO-C00 -U yam -P yam!@ -i %F -o C:\SEL.txt -p -b
IF NOT [%ERRORLEVEL%] == goto get_Error
echo Finished Succesffuly
exit /B 0
echo step Failed
exit /B 40
edited 44 mins ago
asked 53 mins ago
oldest newest votes
up vote 0 down vote
You need two percent signs in your batch file:
FOR %%F IN (C:\SQLCMD*.SQL) DO (
sqlcmd -S LENOVO-C00 -U yam -P yam!@ -i %%F -o C:\SEL.txt -p -b
You could also put the "IF NOT" statement just after the sqlcmd, if you wanted to check for an error after each sql command.
answered 34 mins ago
up vote 0 down vote
Try this line:
FOR %%F IN (C:\SQLCMD\*.SQL) DO sqlcmd -S LENOVO-C00 -U yam -P yam!@ -i %%F -o C:\SEL.txt -p -b
or even better, start debugging with
FOR %%F IN (C:\SQLCMD\*.SQL) DO echo %%F
to see if this loop works, or if there is a problem with the sqlcmd.
|My System Specs|
|24 Aug 2010||#12|
Env var settings:
GLEW=%THIRD_PARTY_ROOT%\GLEW GLEW_1_5_5=%GLEW%\glew-1.5.5 GLEW_BIN_PATH=%GLEW_ROOT%\bin GLEW_INCLUDE_PATH=%GLEW_ROOT%\include GLEW_LIB_PATH=%GLEW_ROOT%\lib GLEW_ROOT=%GLEW_1_5_5% OSG=%THIRD_PARTY_ROOT%\OpenSceneGraph OSG_2_8_3=%OSG%\OpenSceneGraph-2.8.3 OSG_BIN_PATH=%OSG_ROOT%\bin OSG_INCLUDE_PATH=%OSG_ROOT%\include OSG_LIB_PATH=%OSG_ROOT%\lib OSG_ROOT=%OSG_2_8_3% THIRD_PARTY_ROOT=C:\dev\third-party
Output of set:
C:\Users\user>set ALLUSERSPROFILE=C:\ProgramData APPDATA=C:\Users\user\AppData\Roaming CommonProgramFiles=C:\Program Files\Common Files CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files CommonProgramW6432=C:\Program Files\Common Files COMPUTERNAME=USER-PC ComSpec=C:\Windows\system32\cmd.exe FP_NO_HOST_CHECK=NO GLEW=C:\dev\third-party\GLEW GLEW_1_5_5=C:\dev\third-party\GLEW\glew-1.5.5 GLEW_BIN_PATH=C:\dev\third-party\GLEW\glew-1.5.5\bin GLEW_INCLUDE_PATH=C:\dev\third-party\GLEW\glew-1.5.5\include GLEW_LIB_PATH=C:\dev\third-party\GLEW\glew-1.5.5\lib GLEW_ROOT=C:\dev\third-party\GLEW\glew-1.5.5 HOMEDRIVE=C: HOMEPATH=\Users\user LOCALAPPDATA=C:\Users\user\AppData\Local LOGONSERVER=\\USER-PC NUMBER_OF_PROCESSORS=2 OS=Windows_NT OSG=C:\dev\third-party\OpenSceneGraph OSG_2_8_3=C:\dev\third-party\OpenSceneGraph\OpenSceneGraph-2.8.3 OSG_BIN_PATH=C:\dev\third-party\OpenSceneGraph\OpenSceneGraph-2.8.3\bin OSG_INCLUDE_PATH=C:\dev\third-party\OpenSceneGraph\OpenSceneGraph-2.8.3\include OSG_LIB_PATH=C:\dev\third-party\OpenSceneGraph\OpenSceneGraph-2.8.3\lib OSG_ROOT=C:\dev\third-party\OpenSceneGraph\OpenSceneGraph-2.8.3 Path=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program File s\TortoiseSVN\bin;C:\MinGW\bin;C:\Program Files\MySQL\MySQL Server 5.1\bin;C:\Program Files (x86)\CMake 2.8\bin;%THIRD_PARTY_ROOT%\GLEW\glew-1.5.5\bin;%THIRD_PARTY_ROOT%\OpenSceneG raph\OpenSceneGraph-2.8.3\bin PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC PROCESSOR_ARCHITECTURE=AMD64 PROCESSOR_IDENTIFIER=AMD64 Family 16 Model 6 Stepping 2, AuthenticAMD PROCESSOR_LEVEL=16 PROCESSOR_REVISION=0602 ProgramData=C:\ProgramData ProgramFiles=C:\Program Files ProgramFiles(x86)=C:\Program Files (x86) ProgramW6432=C:\Program Files PROMPT=$P$G PSModulePath=C:\Windows\system32\WindowsPowerShell\v1.0\Modules\ PUBLIC=C:\Users\Public SESSIONNAME=Console SystemDrive=C: SystemRoot=C:\Windows TEMP=C:\Users\user\AppData\Local\Temp THIRD_PARTY_ROOT=C:\dev\third-party TMP=C:\Users\user\AppData\Local\Temp USERDOMAIN=user-PC USERNAME=user USERPROFILE=C:\Users\user VS90COMNTOOLS=C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\Tools\ windir=C:\Windows
|My System Specs|
|Thread Tools||Search this Thread|
|Similar help and support threads|
Are USB Cable Length Limits hard limits?
I'm trying to get a longer cable for my digital SLR camera, so I can live preview / shoot from the computer. The camera has about a 3 foot cable with a special USB end. I was just going to order a 15 foot usb extension cable, but this would put me at a total of about 18 feet. Will this extra 2...
|Hardware & Devices|
Set permanent variable in cmd
I am trying to find a way to set a variable in the cmd that is "permanent". What I mean is that I could set the variable %message% to "hello", and I could close the cmd, open it up a week later and if I typed this: echo %message% This would be the result hello Using the normal SET command...
Nesting Virtual Operating Systems
I have a 64 bit version of windows 7 that has the Window XP mode bonus virtual guest OS. So my question is should i nest a virtual OS inside windows XP mode if i want to install MS-Dos a 16 bit operating system or can windows 7 host a 16 bit guest OS
i7 950 OC limits
hey, first what would be a safe clock or an i5 (not asking for like voltage, just a general ghz range) and to support it using a gigabyte x58 usb3 mobo plus, a cheap and effective cooler?
|Hardware & Devices|
Robocopy mass nesting bug
Didn't know where else to put this so I hope this is good. Twice now I have experienced a issue with robocopy where while copying a user folder it mass nests the Application Data folder within Local. It replicates this to both \User\AppData\Local and \User\Local Settings. Weird thing is Local...
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd
All times are GMT -5. The time now is 15:07.