I have an issue with reloading a QlikView document. When I execute a batch file with the command:
"C:\Program Files (x86)\QlikView\Qv.exe" /r "C:\QlikViewMount\reloadvictim.qvw"
the document reloads fine.
But, when I put it into a QlikView Macro (VBScript), it is giving me 'Unknown command line option'.
This is what I used:
strCommand = chr(34) & "C:\Program Files (x86)\QlikView\Qv.exe" & chr(34) & "/r" & chr(34) & "C:\QlikViewMount\reloadvictim.qvw" & chr(34)
The syntax
strCommand = chr(34) & " " ....
makes me think that you want to do a reload of your data when you are in qlikview.
Why not press CTRL+R?
It appears that your command line is missing a couple of spaces either side of your /r parameter, the below should solve your problem:
strCommand = chr(34) & "C:\Program Files (x86)\QlikView\Qv.exe" & chr(34) & " /r " & chr(34) & "C:\QlikViewMount\reloadvictim.qvw" & chr(34)
Related
I would like to get the permission to replace or rename the utilman.exe. The script below is not working.
Dim strFolder, strUser, strDomain
strFolder = "c:\windows\system32\utilman.exe"
Set FSO = CreateObject("Scripting.FileSystemObject")
Set ObjShell = Wscript.CreateObject("Wscript.Shell")
objShell.Run("takeown /A /f" & Chr(34) & strFolder & chr(34)),1,True
objShell.Run("icacls chr(34) & strFodler & chr(34) /grant administrator:F"),1,True
Wscript.quit
You defined the icacls commandline as a single string when you apparently want it to contain the value of the variable strFolder in double quotes. You must use string concatenation for this to work in VBScript. Also, you may want to put a space after the parameter /f of takeown and remove the parentheses around the commands.
Change this:
objShell.Run("takeown /A /f" & Chr(34) & strFolder & chr(34)),1,True
objShell.Run("icacls chr(34) & strFodler & chr(34) /grant administrator:F"),1,True
into this:
objShell.Run "takeown /A /f " & Chr(34) & strFolder & chr(34), 1, True
objShell.Run "icacls " & chr(34) & strFolder & chr(34) & " /grant administrator:F", 1, True
just a quick question. I am trying to execute the following cmd command from vbs:
mklink /j "%userprofile%\AppData\Roaming\FIEBIG\bin" "%Programfiles(x86)%\fiebig-team\fticclient\bin"
with the following code:
Set objShell = WScript.CreateObject("WScript.Shell")
objShell.Run "cmd.exe mklink /j ""%userprofile%\AppData\Roaming\FIEBIG\bin"" ""Programfiles(x86)%\fiebig-team\fticclient\bin"" "
However, no matter what I've tried with adding or excluding quotes, it still does not work.
Can you please help with this,
Cheers
You don't need the CMD.EXE, do you?
strCommand = "mklink /j"
strCommand = strCommand & " "
strCommand = strCommand & Chr(34) & "%userprofile%\AppData\Roaming\FIEBIG\bin" & Chr(34)
strCommand = strCommand & " "
strCommand = strCommand & Chr(34) & "%Programfiles(x86)%\fiebig-team\fticclient\bin" & Chr(34)
objShell.Run strCommand
BTW, here's a debugging trick I use to make sure I get the proper command line. Use an InputBox() and pass your command string as the 3rd parameter. That allows you to copy and paste it to your command prompt window.
InputBox "", "", strCommand
Thanks a lot for your help. I am really into software packaging and just starting coding. How does that look to you?
Set objShell = WScript.CreateObject ("WScript.Shell")
objShell.run
strCommand = "mklink /j"
strCommand = strCommand & " "
strCommand = strCommand & Chr(34) & "%userprofile%\AppData\Roaming\FIEBIG\bin" & Chr(34)
strCommand = strCommand & " "
strCommand = strCommand & Chr(34) & "%Programfiles(x86)%\fiebig-team\fticclient\bin" & Chr(34)
objShell.Run strCommand
I have a problem. I need to throw some synchronized commands in vbscript (one Run method, Delete one and moveFile one) in every cycle to my loop. I don't know how I do it.
My code is that:
Public Function UnificarCRIs(ByVal path, ByVal FICRIEC, ByVal sessio, ByVal CIBAA)
Dim objFile, objCurrentFolder, filesys, origenFitxers
Dim FileName, WshShell
On error resume next
Set filesys = CreateObject("Scripting.FileSystemObject")
Set WshShell = WScript.CreateObject("WScript.Shell")
Set objCurrentFolder = filesys.getFolder(path)
For Each objFile In objCurrentFolder.Files
FileName = objFile
If (right(FileName, 4) = ".cri") Then
If filesys.FileExists(path & FICRIEC & sessio) Then
'WshShell.Run ("copy " & path & FICRIEC & sessio & "+" & FileName & " " & path & FICRIEC & sessio & "_tmp")
WshShell.run ("cmd /K " & "copy /Y " & path & FICRIEC & sessio & "+" & FileName & " " & path & FICRIEC & sessio & "_tmp",8,TRUE)
Set WshShell = Nothing
filesys.DeleteFile path & FICRIEC & sessio
'filesys.MoveFile path & FICRIEC & sessio & "_tmp", path & FICRIEC & sessio
Else
WshShell.run "cmd /K " & "copy /Y " & FileName & " " & path & FICRIEC & sessio,8,TRUE
Set WshShell = Nothing
End If
End If
Next
End Function
Read the docs for .Run completely and reflect on the bWaitOnReturn parameter.
Apology:
Sorry, I didn't read your code carefully enough. The .Run should wait. But I see that you use a global On Error Resume Next and param list () in
WshShell.run ("cmd /K " & "copy /Y " & path & FICRIEC & sessio & "+" & FileName & " " & path & FICRIEC & sessio & "_tmp",8,TRUE)
What happens, when you remove those mistakes? Are you sure, that you have a usable WshShell in the second pass thru the loop?
I need a script that could ran and pull information from any drive on a windows operating system (Server 2003), listing all files and folders which contain the following fields:
Full file path (e.g. C:\Documents and Settings\user\My Documents\testPage.doc)
File type (e.g. word document, spreadsheet, database etc)
Size
When Created
When last modified
When last accessed
Any help is appreciated.
Thanks
try this vbscript
Set objFS=CreateObject("Scripting.FileSystemObject")
Set objArgs = WScript.Arguments
strFolder = objArgs(0)
Set objFolder = objFS.GetFolder(strFolder)
Go (objFolder)
Sub Go(objDIR)
If objDIR <> "\System Volume Information" Then
For Each eFolder in objDIR.SubFolders
Go eFolder
Next
End If
For Each strFile In objDIR.Files
WScript.Echo "Full Path: " & strFile.Path
WScript.Echo "File Size(bytes): " & strFile.Size
WScript.Echo "File Date modified: " & strFile.DateLastModified
WScript.Echo "File Date Created: " & strFile.DateCreated
WScript.Echo "File Date accessed: " & strFile.DateLastAccessed
Next
End Sub
on command line
c:\test> cscript //nologo myscript.vbs c:\
To save the results to a csv file modify ghostdog74's code as follows.
Set objFS=CreateObject("Scripting.FileSystemObject")
WScript.Echo Chr(34) & "Full Path" &_
Chr(34) & "," & Chr(34) & "File Size" &_
Chr(34) & "," & Chr(34) & "File Date modified" &_
Chr(34) & "," & Chr(34) & "File Date Created" &_
Chr(34) & "," & Chr(34) & "File Date Accessed" & Chr(34)
Set objArgs = WScript.Arguments
strFolder = objArgs(0)
Set objFolder = objFS.GetFolder(strFolder)
Go (objFolder)
Sub Go(objDIR)
If objDIR <> "\System Volume Information" Then
For Each eFolder in objDIR.SubFolders
Go eFolder
Next
End If
For Each strFile In objDIR.Files
WScript.Echo Chr(34) & strFile.Path & Chr(34) & "," &_
Chr(34) & strFile.Size & Chr(34) & "," &_
Chr(34) & strFile.DateLastModified & Chr(34) & "," &_
Chr(34) & strFile.DateCreated & Chr(34) & "," &_
Chr(34) & strFile.DateLastAccessed & Chr(34)
Next
End Sub
Then call it from the command line like this.
c:\test> cscript //nologo myscript.vbs "c:\" > "C:\test\Output.csv"
I need a script that can run and pull information from any drive on a Windows operating system (Windows Server 2003), listing all files and folders which contain the following fields: The server is quite big and is within our domain.
The required information is:
Full file path (e.g. C:\Documents and Settings\user\My Documents\testPage.doc)
File type (e.g. word document, spreadsheet, database etc)
Size
When Created
When last modified
When last accessed
Also the script will need to convert that data to a CSV file, which later on I can modify and process in Excel. I can imagine that this data will be huge but I still need it. I am logged in as an administrator on the server and the script will need to also process protected files. As in previous posts I have read that the script will stop if such files are processed. I need to make sure that not a single file is skipped.
Please note I have asked this question before but still have not got a working script.
This is the script I got so far, file Test.vbs:
Set objFS=CreateObject("Scripting.FileSystemObject")
WScript.Echo Chr(34) & "Full Path" &_
Chr(34) & "," & Chr(34) & "File Size" &_
Chr(34) & "," & Chr(34) & "File Date modified" &_
Chr(34) & "," & Chr(34) & "File Date Created" &_
Chr(34) & "," & Chr(34) & "File Date Accessed" & Chr(34)
Set objArgs = WScript.Arguments
strFolder = objArgs(0)
Set objFolder = objFS.GetFolder(strFolder)
Go (objFolder)
Sub Go(objDIR)
If objDIR <> "\System Volume Information" Then
For Each eFolder in objDIR.SubFolders
Go eFolder
Next
End If
For Each strFile In objDIR.Files
WScript.Echo Chr(34) & strFile.Path & Chr(34) & "," &_
Chr(34) & strFile.Size & Chr(34) & "," &_
Chr(34) & strFile.DateLastModified & Chr(34) & "," &_
Chr(34) & strFile.DateCreated & Chr(34) & "," &_
Chr(34) & strFile.DateLastAccessed & Chr(34)
Next
End Sub
I am currently using the command-line to run it:
c:\test> cscript //nologo Test.vbs "c:\" > "C:\test\Output.csv"
The script is not working. I don't know why.
Properly passing cmd-line args to vbs when using Cscript
-Modify the cmd-line statement as follows (drop the ">")
c:\test> cscript //nologo Test.vbs "c:\" "C:\test\Output.csv"
-Next inside the script you can access the cmd-line parameters as follows
strFolder = WScript.Arguments.Item(0)
strFile = WScript.Arguments.Item(1)
I hope now you can access the files and list them properly in the csv-file. :-)
GoodLUCK!!
- CVS