abinsierra

New Member
Joined
Aug 26, 2012
Messages
2
Hi guys,

For security reasons, I had turned off/disable some features on my Windows 7, i.e: Prevent installed programs, disable command prompt and batch files, disable access to registry files, disable snap-in, disable taskmanager, and last disable regedit.

I need a windows script to run these stages :
First, delete some files, assumed C:\Program Files\gaming\data\log.txt and then execute the application on C:\Program Files\gaming\Apps\glick.exe

I consider to use a batch file, but it cannot be executed for the accessed is denied. So instead, the windows scripting in vbs will be a solution.

I do need help from the expert.
Regards.
 

Solution
To achieve the tasks you've described, we can use a Windows VBScript to delete the specified file and then launch the application. Here is a VBScript that you can use for this purpose:
Code:
Set objFSO = CreateObject("Scripting.FileSystemObject") ' Path to the file to delete strFileToDelete = "C:\Program Files\gaming\data\log.txt" ' Check if the file exists before deleting If objFSO.FileExists(strFileToDelete) Then objFSO.DeleteFile strFileToDelete WScript.Echo "File deleted successfully." Else WScript.Echo "File not found." End If ' Path to the application to run strAppPath = "C:\Program Files\gaming\Apps\glick.exe" ' Check if the application exists before running If objFSO.FileExists(strAppPath) Then Set objShell =...

WindowsForum AI

AI
Staff member
Robot
Joined
Mar 14, 2023
Messages
114,020
To achieve the tasks you've described, we can use a Windows VBScript to delete the specified file and then launch the application. Here is a VBScript that you can use for this purpose:
Code:
Set objFSO = CreateObject("Scripting.FileSystemObject") ' Path to the file to delete strFileToDelete = "C:\Program Files\gaming\data\log.txt" ' Check if the file exists before deleting If objFSO.FileExists(strFileToDelete) Then objFSO.DeleteFile strFileToDelete WScript.Echo "File deleted successfully." Else WScript.Echo "File not found." End If ' Path to the application to run strAppPath = "C:\Program Files\gaming\Apps\glick.exe" ' Check if the application exists before running If objFSO.FileExists(strAppPath) Then Set objShell = CreateObject("WScript.Shell") objShell.Run Chr(34) & strAppPath & Chr(34), 1, False WScript.Echo "Application launched successfully." Else WScript.Echo "Application not found." End If
Save this script with a .vbs extension, for example, execute_tasks.vbs. To run this script, you can double-click on it, and it should carry out the steps you specified: deleting the file C:\Program Files\gaming\data\log.txt and then launching the application located at C:\Program Files\gaming\Apps\glick.exe. If you encounter any errors running the script due to restricted permissions, you might need to adjust the security settings or run the script as an administrator.
 

Solution