Is there any way to make a .vbs file Read only,so that no one rather a specific person can read the content or change the content? But only can double click on that file to start its execution. I will set up a Main.vbs into which I would put the below
Dim oShell : Set oShell = WScript.CreateObject ("WScript.Shell")
oShell.run "A.VBS", 1, True
oShell.run "B.VBS", 1, True
oShell.run "C.VBS", 1, True
oShell.run "D.VBS", 1, True
The user will click only on the main.vbs to start the execution. All the .vbs I want to be Read/write protected. is my thought possible in practice?
Thanks,
If you can't read it you can't run it.
You can set permissions so that no other person (except administrators) can change the file, but you can't prevent people from being able to read the file if they're supposed to be able to run it.
Some other options to consider. The script can be encoded with the Microsoft Script Encoder. This will make it unreadable. One download link here (can't find the official Microsoft download link) http://www.softpedia.com/get/Programming/Packers-Crypters-Protectors/Microsoft-Script-Encoder.shtml. Of course, it is possible for people to decode the file using the appropriate tool.
Another option is to digitally sign the script with a code-signing certificate. This will still allow it to be viewed, but it will not be able to be modified without breaking the digital signature.
Or even encode the script then digitally sign it.
If the purpose of this is to protect your code, then you can always make an executable file.
Related
I found how to make this
Download_Example
I have a question about how to make execute VBS in vb6 (VBS haves form3 (from vb6 project .)show)
I made a dialog with Microsoft common dialog control 6.0
CommonDialog1.Filter = "File (*.vbs)|*.txt|All Files (*.*)|*.*"
CommonDialog1.DefaultExt = "vbs"
CommonDialog1.DialogTitle = "Select File"
CommonDialog1.ShowOpen
The FileName property gives you the variable you need to use
A work-around might be just executing the script using Shell.
Shell "wscript.exe c:\myscript.vbs", vbNormalFocus
Shell "wscript.exe " & CommonDialog1.FileName, vbNormalFocus
See Microsoft's wscript documentation.
vbNormalFocus is there to restore focus to your vb6 program. It is optional but you probably want it. See documentation.
Looks like you are trying to run a VBScript from your VB6 app to open a dialog in the VB6 app.
VB6 -> VBScript -> Same VB6
You cannot do this with Shell since it runs the script as a separate process. The Script does not know what Form3 is because it is a component of the VB6 app and would not exist as a separate entity once the app is compiled.
Edit: Looks like what you want to do is possible but with Microsoft Script Control. Here are a few examples. Thank you #GSerg for pointing this out.
This or this might be used as a work-around but I don't think it is the right way to go.
Go back to your requirements. What exactly are you trying to accomplish? There has to be a better way.
I have written a VBScript that helps me organise my desktop every time it gets messy.
It works fine it moves my files and shortcuts based on the extension and the name of the app. However, I have a few app shortcut links that just won't move. in fact the vbs script will not even see them with this basic script
Set FSO = CreateObject("Scripting.FileSystemObject")
dir = CreateObject("Scripting.FileSystemObject").GetParentFolderName(WScript.ScriptFullName)
Set folder = FSO.GetFolder(dir)
Set files = folder.Files
For Each file in files
MsgBox file.Name
Next
The files in question are all shortcuts they are iTunes, VLC, Google Chrome and WinRar.
Is there anything I can check to see why vbs won't even see these files?
What You can see on your desktop is hybrid view of two folders:
C:\Users\YourUsername\Desktop
C:\Users\Public\Desktop
Where the Public one is usually a place, where shortcuts are being created during app install, so all users do have them. In your script You are only looking for files in the YourUserName\Desktop, that's why the script does not see those shortcuts.
Is there any way to launch default browser from intallshield after completing installation?
I followed installshield 2008 how to open url when install sucessfully completes. but did not understand how to do it.
Do we have any elegant way to do it?
Yes.
Here is what is needed to be done.
Write a batch file or vbscript that opens the url you want.
Convert that bat file into an exe using any of the converters available.
Call that exe via custom action.
Schedule that custom action after installation completes. i.e. After='InstallFinalize'.
You may also want to detect the default browser which you can do by googling the registry key.
The easiest way to do what you want would be to create the custom action as he said and go to the finish button and add action, choose your custom action and add the condition "NOT INSTALLED", so it only runs when it is installed and not for example while unisntalling.
Here is some sample code.
Dim iURL As String
Dim objShell
iURL = "www.happycat.com"
objShell = CreateObject("Shell.Application")
objShell.ShellExecute("C:\Program Files (x86)\Google\Chrome\Application\chrome.exe", iURL, "", "", 1)
I would like to operate a (Windows) Desktop program. Because i use this on a daily basis to do some simple operaition. (Open a file PDF file, render it and save it in another folder).
I would like to do this by using somekind of service or script. I have been looking into VBscript to do this but i'm getting stuck at some operations that are normally done by users.
For example if i would like to open a file a user would go to File > Open and select the desired file. Off course the script could go to file and open but how do you select a certain file (the newest file in a certain folder).
Is it possible to have a piece of code to do these operations within a Desktop program or am i trying to do something impossible or maybe i'm using the wrong tools. Below a piece off testcode for what i'm trying to accomplish.
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run """C:\Program Files (x86)\programname.exe"""
wsh.sleep 1000 ' wait 1 second
WshShell.AppActivate """Program name"""
WshShell.SendKeys "^o" ' Open file
Any help is greatly appreaciated.
You are trying to control an application through its GUI, but it is not designed for that.
Having said that, I estimate this will be a nightmare if you do not use tools (or an app :-) ) explicitely created for that purpose, a la test robots like HP QTP or automation tools like Autoit http://www.autoitscript.com/site/autoit.
For example, if your application occasionally flushes the keyboard buffer, you might need to wait for some GUI event before sending the keystroke. This kind of synchronization is not accomplishable using vbscript only.
I have compiled 2 VBScript .vbs files in an attempt to control the use of smart quotes (also known as curly quotes) in Microsoft Word. I am experimenting with using VBScript to undertake Microsoft Word functions.
The outcome I would like is as follows: whilst having a Microsoft word document open, I would like to be able to open one of the .vbs files to turn smart quotes on effective immediately, and conversely be able to open the other .vbs file to turn smart quotes off effective immediately.
Unfortunately, whilst having a Microsoft word document open, running these scripts by double clicking the appropriate .vbs file appears to have no effect.
However, if I open (by double clicking) one of the .vbs files whilst Microsoft word is closed, and then open Microsoft word, the smart quotes settings will reflect the script in the .vbs file.
I have reproduced the scripts from the .vbs files below. There is a line of junk code in each one preceded by an apostrophe - as I said I have been experimenting.
How do I amend the scripts to achieve the aforementioned outcome?
Any assistance is greatly appreciated. Stuartzz
Script (in a .vbs file) for turning smart quotes off:
On Error Resume Next
Set objWord = CreateObject("Word.Application")
'objWord.Visible = True
Set objOptions = objWord.Options
objOptions.AutoFormatAsYouTypeReplaceQuotes = False
objOptions.AutoFormatReplaceQuotes = False
ObjWord.Quit
Script (in a .vbs file) for turning smart quotes on:
On Error Resume Next
Set objWord = CreateObject("Word.Application")
'objWord.Visible = True
Set objOptions = objWord.Options
objOptions.AutoFormatAsYouTypeReplaceQuotes = True
objOptions.AutoFormatReplaceQuotes = True
ObjWord.Quit
VBScript version 5.8.7601.16978
.net framework version v4.0.30319
Windows 7 Ultimate Service Pack 1 64-bit operating system
Microsoft Office Professional Plus 2010
Microsoft Word 14.0.5128.5000 (64-bit)
Using CreateObject will start a new instance of the Word application. It will not affect a currently running one. To get a currently running instance, you need to use GetObject.
So, instead of this:
Set objWord = CreateObject("Word.Application")
Use this to grab first instance of Word:
Set objWord = GetObject(, "Word.Application")
All of that being said, if you used a macro written in VBA, it would always run within the currently open file. You could even apply a toolbar button for easier access.